Shoot, Reload, Repeat
Submissions: 765   Accuracy:


  Difficulty: Easy   Marks: 2

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 : 

Output : 

Explanation : 
Case 1 : 

Gun capacity = 3
Bullets available at beginning = 3

Ishaan shoots 3 bullets and then reloads,
again bullets available are 3 after reload.

Now he shoots 1 bullet and reloads,
bullets available = 3.

Then he shoots 2 bullets.
So the activities are valid.

** For More Input/Output Examples Use 'Expected Output' option **

Author: goyalanubhav11

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.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.