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.

d_Coder00 | 134 |

dungeon_master1299 | 126 |

Astikeysingh | 120 |

rajendrashekhawat063 | 115 |

kaustavbhattachaarya | 111 |

Pulkit__Sharma__ | 646 |

Anirban166 | 531 |

abducodes | 501 |

Found_me | 454 |

Yo_Nehru | 404 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4559 |

Login to report an issue on this page.