Hide

Problem H
Fish Census

Every decade or two the commerce department requires a careful census of all fish in captivity. To make it easier, each pet store sends an image of their aquariums using a special camera that produces an ASCII image such as the one shown below.

                                          <.}}><         
            ____        ><{{{'>                          
         \\/ > o\                                        
         //\____/                    ><{{*>              
                               _____  _        <'}}}}}}><
           <'}}}><            /o  ) \/ /                 
                              \_____/\_\                 
                                                         
                   <'))><                        ><{{*>  
         ><((('>               <'}}}}}}><                
                                            <*}}><       
                       <")))><                           
              ><{{'>      . ><(((">       <")))><  ><{{*>
                       .                                 
          <'}}><         .     ><{{'>            ><{{*>  
                       .                                 
                        .              <*}}><            
          \|/          ||         \|/             \|/    

This year only founder, koi and trout will be counted. Of course these fish could be swimming either left or right and they may have grown to different lengths.

><(("><"}}}}><

example flounder

><(((*><*}}}><

example koi

><{{{{'><'))><

example trout

Right swimming fish always consist of a greater-than (>), less-than (<), some scales (( or {), an eye (" or * or '), and a greater-than. Similarly, left swimming fish always consist of a less-than, an eye, some scales () or }), greater-than, and a less-than. Flounder, koi, and trout have unique eyes as shown in the examples above. Fish scales (open or close) depend on the swim direction, and must be the same for each fish. Any physically disabled fish, or any other things in the tank should not be considered in this census.

Given an aquarium image, report the number of flounder, koi, and trout.

Input

The first line of input contains the number of data sets ($1 \le n \le 100$) to process. Each data set consists of the image height and width ($1 \le h,w \le 200$) on a single line, separated by a space. The next $h$ lines each contain $w$ characters. All row characters are either a printable ASCII character or a space; and the last character is a pipe (|).

Output

Each data set should produce one line of output with three integers, separated by a space, indicating respectively the number of flounder, koi, and trout in the image.

Sample Input 1 Sample Output 1
2
18 50
                                  <.}}><         |
   ____        ><{{{'>                           |
\\/ > o\                                         |
//\____/                     ><{{*>              |
                       _____  _        <'}}}}}}><|
   <'}}}><            /o  ) \/ /                 |
                      \_____/\_\                 |
                                                 |
           <'))><                        ><{{*>  |
><((('>             <'}}}}}}><                   |
                                    <*}}><       |
               <")))><                           |
      ><{{'>      . ><(((">       <")))><  ><{{*>|
               .                                 |
  <'}}><         .     ><{{'>            ><{{*>  |
               .                                 |
                .              <*}}><            |
  \|/          ||         \|/             \|/    |
4 11
><('><'}><|
<*})})})><|
<')><*))><|
><'><'><><|
3 6 9
0 1 3

Please log in to submit a solution to this problem

Log in