Ishaan has bought a new gun. He is practicing his shooting, but he has to reload his gun again and again.

You are given his shooting a bullet and reloading activity in the form of a string S.

String S consists of 2 type of distinct characters :

S: stands for shooting one bullet

R: stands for reloading the gun

You are also given an integer N, which is the bullet capacity of the gun. Each time Ishaan reloads the gun, it is filled up to N bullets.

Given the string S and integer N, find out whether the activities are valid or not ( Refer example for explanation ).

Assume that the gun is loaded upto its full capacity in the beginning of each test case.

**Input :**

The first line of input contains a single integer T denoting the number of test cases.The first of each test case line contains the string S.The second line of each test case contains an integer N.

**Output : **

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

**Constraints : **

1 <= T <= 100

1 <= N <= 100

1 <= Length of S <= 500

**Example :
Input : **

3

SSSRSRSS

3

RSSRS

2

SSSSRS

3

1

1

0

**Explanation :
Case 1 : **

SSSRSRSS

Gun capacity = 3

Bullets available at beginning = 3

Ishaan shoots 3 bullets and then reloads,

**SSSR**SRSS

again bullets available are 3 after reload.

Now he shoots 1 bullet and reloads,

SSSR**SR**SS

bullets available = 3.

Then he shoots 2 bullets.

SSSRSR**SS**

So the activities are valid.

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.

_Shubham_Jain_06 | 404 |

maggiiiii | 315 |

Savage_19 | 310 |

ritikdagar0203 | 241 |

thanuvinu94 | 233 |

Bishnu Dev Panda | 810 |

_Shubham_Jain_06 | 715 |

okayboss | 652 |

maggiiiii | 598 |

Savage_19 | 576 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4925 |

Quandray | 4547 |

Login to report an issue on this page.