五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CF 1287A - Angry Students

2023-06-20 11:26 作者:您是打尖兒還是住店呢  | 我要投稿

It's a walking tour day in SIS.Winter, so t

?groups of students are visiting Torzhok. Streets of Torzhok are so narrow that students have to go in a row one after another.


Initially, some students are angry. Let's describe a group of students by a string of capital letters "A" and "P":


"A" corresponds to an angry student

"P" corresponds to a patient student

Such string describes the row from the last to the first student.


Every minute every angry student throws a snowball at the next student. Formally, if an angry student corresponds to the character with index i

?in the string describing a group then they will throw a snowball at the student that corresponds to the character with index i+1

?(students are given from the last to the first student). If the target student was not angry yet, they become angry. Even if the first (the rightmost in the string) student is angry, they don't throw a snowball since there is no one in front of them.



Let's look at the first example test. The row initially looks like this: PPAP. Then, after a minute the only single angry student will throw a snowball at the student in front of them, and they also become angry: PPAA. After that, no more students will become angry.


Your task is to help SIS.Winter teachers to determine the last moment a student becomes angry for every group.

Input

The first line contains a single integer t — the number of groups of students (1≤t≤100). The following 2t

?lines contain descriptions of groups of students.

The description of the group starts with an integer ki (1≤ki≤100) — the number of students in the group, followed by a string si, consisting of ki letters "A" and "P", which describes the i-th group of students.


Output

For every group output single integer — the last moment a student becomes angry.


Examples

input

1

4

PPAP

output

1

input

3

12

APPAPPPAPPPP

3

AAP

3

PPA

output

4

1

0

Note

In the first test, after 1

?minute the state of students becomes PPAA. After that, no new angry students will appear.


In the second tets, state of students in the first group is:


after 1

?minute — AAPAAPPAAPPP

after 2

?minutes — AAAAAAPAAAPP

after 3

?minutes — AAAAAAAAAAAP

after 4

?minutes all 12

?students are angry

In the second group after 1

?minute, all students are angry.

一些小tips的地方?jīng)]注意,結(jié)果一直沒過,確認(rèn)更改就可以了;

也有好的方法;while(!s.equals(s.replace("AP","AA")) 這個(gè)就可以了;


CF 1287A - Angry Students的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國家法律
长葛市| 始兴县| 黄骅市| 安乡县| 宝清县| 虹口区| 曲沃县| 沙田区| 乳山市| 易门县| 军事| 揭东县| 锡林郭勒盟| 綦江县| 吴桥县| 清水河县| 屏东县| 呼图壁县| 普洱| 扬州市| 天全县| 清流县| 荆门市| 睢宁县| 苏尼特左旗| 华阴市| 区。| 镇原县| 两当县| 温宿县| 平阴县| 博客| 广元市| 寿光市| 西乡县| 杭锦后旗| 新疆| 南丰县| 攀枝花市| 谢通门县| 黄石市|