There are N office cubicles placed in a straight line, each with a bright bulb. Each light bulb can brighten K rooms on either side of it (also the one in which the light bulb itself is), but all the cubicles don't have a bulb.

You are given an array A which gives the information about the location of the bulbs. If A[i] is equal to 1, then the cubicle has a light bulb, else if A[i] is 0, then the cubicle doesn't have a bulb.

You need to find out whether all the cubicles are bright or not.

**Input :**

The first line of input contains a single integer T denoting the number of test cases.The first line of each test case contains 2 space-separated integers N and K.The second line contains N space-separated integers denoting the array A.

**Output : **

For each test case, print "1" if all the cubicles are brightened, else "0" (without quotes " ") in a new line.

**Constraints : **

1 <= T <= 100

1 <= N <= 500

1 <= K <= 20

0 <= A[i] <= 1

**Example :
Input : **

3

4 3

0 1 0 1

1 1

1

7 2

1 0 0 0 0 0 1

1

1

0

**Explanation :
Case 1 : **

The first and third cubicles do not have bulbs.

Since K=3, first can be brightened by second and third can be brightened by fourth.

**Case 2 : **

All cubicles have bulbs.

**Case 3 : **

Since K=2, the second and third cubicle can be brightened by the first one, the fifth and sixth can be brightened by the seventh one.

But the fourth cubicle cannot be brightened by any of the bulbs, so the answer is 0.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

VISHESHA SADU | 27 |

ghanshyam648 | 25 |

Biswajit3 | 21 |

karthik_kasaragadda | 20 |

tanya_sharma | 18 |

KshatriyaYash | 1066 |

nikhil_sojan | 978 |

lonecoder | 935 |

mazumderrohit8 | 864 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4468 |

Quandray | 4444 |

Login to report an issue on this page.