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.

agness | 122 |

aman1931998 | 102 |

Survivor | 100 |

uchitnitk | 96 |

lonecoder | 95 |

KshatriyaYash | 1066 |

nikhil_sojan | 1032 |

lonecoder | 1030 |

mazumderrohit8 | 899 |

SumitSingh27 | 832 |

blackshadows | 5327 |

Ibrahim Nash | 5215 |

akhayrutdinov | 5111 |

mb1973 | 4492 |

Quandray | 4444 |

Login to report an issue on this page.