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.

murli01 | 343 |

decoder_101 | 274 |

john_wick | 204 |

singhalsaurav1997 | 196 |

Sulagna | 189 |

john_wick | 725 |

PiyushPandey4 | 717 |

ASWATHAMA | 565 |

akhyasharma01 | 547 |

decoder_101 | 512 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.