CF510B Fox And Two Dots
Description
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size $ n×m $ cells, like this:
Each cell contains a dot that has some color. We will use different uppercase Latin characters to express different colors.
The key of this game is to find a cycle that contain dots of same color. Consider 4 blue dots on the picture forming a circle as an example. Formally, we call a sequence of dots $ d_{1},d_{2},...,d_{k} $ a cycle if and only if it meets the following condition:
1. These $ k $ dots are different: if $ i≠j $ then $ d_{i} $ is different from $ d_{j} $ .
2. $ k $ is at least 4.
3. All dots belong to the same color.
4. For all $ 1
Input Format
N/A
Output Format
N/A
Explanation/Hint
In first sample test all 'A' form a cycle.
In second sample there is no such cycle.
The third sample is displayed on the picture above ('Y' = Yellow, 'B' = Blue, 'R' = Red).