Time limit
1s
Memory limit
128 MB
Changyoung finally got a job. He had not found a workplace he liked until now, but this time he joined a candy factory. He expected working at a candy factory to be sweet, but inspecting candy quality for eight hours turned out to be extremely boring.
Candy quality is inspected as follows. First, open a box full of candies. Then count the number of candies and the number of empty spots.
Unable to endure the boredom, Changyoung decided to write a program for the inspection.
You are given an r by c matrix viewed from above the box. The matrix contains only the following characters.
.": empty spoto": edible part of a candy<>v^": candy wrapperA candy has only one of the following two shapes.
>o<vo^Only three consecutive characters exactly matching one of these shapes form a candy.
A partial shape, such as >o., may appear, but it is not counted as a candy.
Given the r by c matrix, write a program that prints the number of candies in the box.
The first line contains the number of test cases t. Test cases are separated by a blank line.
For each test case, the first line contains r and c (1 <= r, c <= 400). The next r lines contain the rows of the matrix in order. Each row has exactly c characters and contains only ".o<>v^". Their ASCII values are 46, 111, 60, 62, 118, and 94.
For each test case, print one integer on its own line: the number of candies in the box.
An input like the following will not be given.
v>o< ^>o<vo^ v>o< ^