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. 



You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).

Input

The first line contains two integer numbers n and 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 description of the field.

Output

Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).

Examples

Input

6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG


Output

YES


Input

4 3
BRG
BRG
BRG
BRG


Output

YES


Input

6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB


Output

NO


Input

4 4
RRRR
RRRR
BBBB
GGGG


Output

NO

Note

The field in the third example 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.
#include <bits/stdc++.h>
void sf(int &x) { scanf("%d", &x); }
void sf(char &x) { scanf("%c", &x); }
void sf(double &x) { scanf("%lf", &x); }
void sf(char *x) { scanf("%s", x); }
void sf(long long &x) { scanf("%I64d", &x); }
void pf(int x) { printf("%d", x); }
void pf(char x) { printf("%c", x); }
void pf(double x) { printf("%f", x); }
void pf(char *x) { printf("%s", x); }
void pf(long long x) { printf("%I64d", x); }
void pf() { printf("\n"); }
const long long mod = 1e9 + 7;
const int maxn = 100010;
const int INF = 0x7ffffff;
const long long LINF = 0x7fffffffffffffff;
using namespace std;
long long q_pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    y >>= 1;
    x = (x * x) % mod;
  }
  return res;
}
long long inv(long long x) { return q_pow(x, mod - 2); }
int Read() {
  int x = 0, F = 1;
  char C = getchar();
  while (C < '0' || C > '9') {
    if (C == '-') F = -F;
    C = getchar();
  }
  while (C >= '0' && C <= '9') {
    x = x * 10 - '0' + C, C = getchar();
  }
  return x * F;
}
int Trans() {
  char c;
  sf(c);
  int res;
  res = c - '0';
  return res;
}
int MAXNUM;
char maze[105][105];
int color[3];
int main() {
  int col, row;
  cin >> row >> col;
  int cnt = 0;
  char cur = 0;
  int flag = 1;
  for (int i = 0; i < row; i++) {
    cin >> maze[i];
  }
  for (int i = 0; i < row; i++) {
    if (i == 0) {
      cur = maze[0][0];
      if (cur == 'R') {
        color[0]++;
      }
      if (cur == 'B') {
        color[1]++;
      }
      if (cur == 'G') {
        color[2]++;
      }
    } else {
      cur = maze[i][0];
      char pre = maze[i - 1][0];
      if (cur != pre) {
        if (cur == 'R') {
          if (color[0]) {
            printf("NO\n");
            return 0;
          }
        }
        if (cur == 'B') {
          if (color[1]) {
            printf("NO\n");
            return 0;
          }
        }
        if (cur == 'G') {
          if (color[2]) {
            printf("NO\n");
            return 0;
          }
        }
      }
      if (cur == 'R') {
        color[0]++;
      }
      if (cur == 'B') {
        color[1]++;
      }
      if (cur == 'G') {
        color[2]++;
      }
    }
    for (int j = 0; j < col; j++) {
      if (maze[i][j] != maze[i][0]) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) break;
  }
  if (flag == 1) {
    int x = color[0];
    for (int i = 1; i < 3; i++) {
      if (color[i] != x) {
        flag = 0;
      }
    }
  }
  if (flag) {
    printf("YES\n");
    return 0;
  } else {
    flag = 1;
    memset(color, 0, sizeof(color));
    for (int i = 0; i < col; i++) {
      if (i == 0) {
        cur = maze[0][0];
        if (cur == 'R') {
          color[0]++;
        }
        if (cur == 'B') {
          color[1]++;
        }
        if (cur == 'G') {
          color[2]++;
        }
      } else {
        cur = maze[0][i];
        char pre = maze[0][i - 1];
        if (cur != pre) {
          if (cur == 'R') {
            if (color[0]) {
              printf("NO\n");
              return 0;
            }
          }
          if (cur == 'B') {
            if (color[1]) {
              printf("NO\n");
              return 0;
            }
          }
          if (cur == 'G') {
            if (color[2]) {
              printf("NO\n");
              return 0;
            }
          }
        }
        if (cur == 'R') {
          color[0]++;
        }
        if (cur == 'B') {
          color[1]++;
        }
        if (cur == 'G') {
          color[2]++;
        }
      }
      for (int j = 0; j < row; j++) {
        if (maze[j][i] != maze[0][i]) {
          flag = 0;
          break;
        }
      }
      if (flag == 0) break;
    }
    if (flag == 1) {
      int x = color[0];
      for (int i = 1; i < 3; i++) {
        if (color[i] != x) {
          flag = 0;
        }
      }
    }
    if (flag) {
      printf("YES\n");
      return 0;
    } else
      printf("NO\n");
  }
  return 0;
}
