1531: CF837 - B. Flag of Berland
[Creator : ]
Description
The flag of Berland is such rectangular field $n×m$ that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R','G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
Input
The first line contains two integer numbers $n,m\ (1≤n,m≤100)$ − the sizes of the field.
Each of the following $n$ lines consisting of $m$ characters 'R','G' and 'B' − the desc
Output
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
Sample 1 Input
6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG
Sample 1 Output
YES
Sample 2 Input
4 3
BRG
BRG
BRG
BRG
Sample 2 Output
YES
Sample 3 Input
6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB
Sample 3 Output
NO
The field doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights − $2,1$ and $1$.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights − $2,1$ and $1$.
4 4
RRRR
RRRR
BBBB
GGGG
NO