Under construction

Still being built. Things may change

Longest Run of X's

Interview

Time limit1sMemory limit256 MB

Summary
Count the longest run of consecutive X marks in each hallway and print its length in the required sentence.
Level

Easy1 of 10

Topics
Array
Solved
No attempts yet

Problem

Gru and Lucy are breaking into El Macho's lair. In front of them is a hallway that may be booby-trapped. The hallway is a single row of squares, and every square is marked either X or O. Gru believes that only the squares in the longest run of consecutive X marks are safe.

For each hallway, count how many squares are safe.

Input

The first line contains the number of test cases TT. TT is less than 100.

Each of the following lines holds one test case. The first number on the line is the number of squares nn, followed by nn strings separated by spaces. Each string is either X or O.

nn is at least 1, and the sum of nn over all test cases is at most 200000.

Output

For each test case, find the length LL of the longest run of consecutive X marks and print one line in this format.

The longest contiguous subsequence of X's is of length L

Write LL as a plain integer. If the hallway has no X at all, LL is 0.

Examples4

  1. Example 1

    Input
    3
    10 X O O O O X O O O X  
    5 O O O O O
    4 X X X X 
    
    Expected output
    The longest contiguous subsequence of X's is of length 1
    The longest contiguous subsequence of X's is of length 0
    The longest contiguous subsequence of X's is of length 4
    
  2. Example 2

    Input
    1
    1 X
    
    Expected output
    The longest contiguous subsequence of X's is of length 1
    
  3. Example 3

    Input
    1
    1 O
    
    Expected output
    The longest contiguous subsequence of X's is of length 0
    
  4. Example 4

    Input
    2
    8 X X O X X X O X
    8 X X X O X X O O
    
    Expected output
    The longest contiguous subsequence of X's is of length 3
    The longest contiguous subsequence of X's is of length 3