Chocolate is Tasty
시간 제한2초메모리 제한512 MB
n x m 초콜릿과 원형으로 앉은 아이들이 주어지고, 욕심 많은 남자아이는 긴 변에서, 몸매를 관리하는 여자아이는 짧은 변에서 한 줄씩 먹는다. 서로 다른 아이가 최대로 많이 먹도록 시작 위치를 정한다.
문제
A mother wishes to share a chocolate bar among her children. A child can be either a boy or a girl. The children sit in a circle and consecutively take a line of chocolate in clockwise order. At the beginning, the chocolate bar has rows and columns. Each boy is greedy and takes one line from the longer side of the chocolate bar. Each girl wishes to keep fit so she takes one line from the shorter side. Mother has to choose from which child she should start to maximize the number of kids that will share the chocolate.
입력
The first line of input consists of , the number of test cases. The description of the test cases follows.
Each line consists of two integers and separated by a space (). They are followed by a space and a sequence of letters "B" and "G" which identify the children on the circle in clockwise order. The length of the sequence is not greater than .
출력
For each test case, print a line with single a interger: the maximal number of children that can eat a chocolate. Do not count the same kid twice even if he/she receive the chocolate twice.