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>
using namespace std;
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
template <typename T>
T max(T a, T b, T c, T d) {
  return max(a, max(b, max(c, d)));
}
template <typename T>
T min(T a, T b, T c, T d) {
  return min(a, min(b, min(c, d)));
}
template <typename t1>
void fill(vector<t1> &arr, t1 val) {
  for (long long i = 0; i < (long long)arr.size(); i++) arr[i] = val;
}
template <typename t1>
void fill(vector<vector<t1>> &arr, t1 val) {
  for (long long i = 0; i < (long long)arr.size(); i++) {
    for (long long j = 0; j < (long long)arr[i].size(); j++) arr[i][j] = val;
  }
}
template <typename T>
void read(vector<T> &arr, long long N) {
  arr.clear();
  arr.resize(N);
  for (long long i = 0; i < N; i++) cin >> arr[i];
}
template <typename T>
void read(vector<pair<T, T>> &arr, long long N) {
  arr.clear();
  arr.resize(N);
  for (long long i = 0; i < (long long)arr.size(); i++)
    cin >> arr[i].first >> arr[i].second;
}
template <typename T>
void read(vector<vector<T>> &arr, long long N, long long M) {
  arr.clear();
  arr.resize(N, vector<T>(M));
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < M; j++) cin >> arr[i][j];
  }
}
template <typename T, size_t N>
long long SIZE(const T (&t)[N]) {
  return N;
}
template <typename T>
long long SIZE(const T &t) {
  return t.size();
}
string to_string(const string s, long long x1 = 0, long long x2 = 1e9) {
  return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"';
}
string to_string(const char *s) { return to_string((string)s); }
string to_string(const bool b) { return (b ? "true" : "false"); }
string to_string(const char c) { return string({c}); }
template <size_t N>
string to_string(const bitset<N> &b, long long x1 = 0, long long x2 = 1e9) {
  string t = "";
  for (long long __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1);
       __iii__ <= __jjj__; ++__iii__) {
    t += b[__iii__] + '0';
  }
  return '"' + t + '"';
}
template <typename A, typename... C>
string to_string(const A(&v), long long x1 = 0, long long x2 = 1e9,
                 C... coords);
long long l_v_l_v_l = 0, t_a_b_s = 0;
template <typename A, typename B>
string to_string(const pair<A, B> &p) {
  l_v_l_v_l++;
  string res = "" + to_string(p.first) + ", " + to_string(p.second) + "";
  l_v_l_v_l--;
  return res;
}
template <typename A, typename... C>
string to_string(const A(&v), long long x1, long long x2, C... coords) {
  long long rnk = rank<A>::value;
  string tab(t_a_b_s, ' ');
  string res = "";
  bool first = true;
  if (l_v_l_v_l == 0) res += '\n';
  res += tab + "[ ";
  x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v));
  auto l = begin(v);
  advance(l, x1);
  auto r = l;
  advance(r, (x2 - x1) + (x2 < SIZE(v)));
  for (auto e = l; e != r; e = next(e)) {
    if (!first) {
      res += ", ";
    }
    first = false;
    l_v_l_v_l++;
    if (e != l) {
      if (rnk > 1) {
        res += '\n';
        t_a_b_s = l_v_l_v_l;
      };
    } else {
      t_a_b_s = 0;
    }
    res += to_string(*e, coords...);
    l_v_l_v_l--;
  }
  res += "]\n";
  if (l_v_l_v_l == 0) res += '\n';
  return res;
}
void dbgm() { ; }
template <typename Heads, typename... Tails>
void dbgm(Heads H, Tails... T) {
  cout << to_string(H) << " | ";
  dbgm(T...);
}
static bool comp(pair<long long, long long> &a, pair<long long, long long> &b) {
}
const long long Max = 2 * 1e15, Min = -2 * 1e15;
const long long mod = 1e9 + 7;
long long N, M, K;
const long long P = 31;
vector<vector<char>> arr;
bool row(char c1, char c2, char c3) {
  if (N % 3 != 0) return false;
  long long i = 0;
  for (long long cnt = 0; cnt < N / 3; cnt++) {
    for (long long j = 0; j < M; j++) {
      if (arr[i][j] != c1) return false;
    }
    i++;
  }
  for (long long cnt = 0; cnt < N / 3; cnt++) {
    for (long long j = 0; j < M; j++) {
      if (arr[i][j] != c2) return false;
    }
    i++;
  }
  for (long long cnt = 0; cnt < N / 3; cnt++) {
    for (long long j = 0; j < M; j++) {
      if (arr[i][j] != c3) return false;
    }
    i++;
  }
  return true;
}
bool col(char c1, char c2, char c3) {
  if (M % 3 != 0) return false;
  long long j = 0;
  for (long long cnt = 0; cnt < M / 3; cnt++) {
    for (long long i = 0; i < N; i++) {
      if (arr[i][j] != c1) return false;
    }
    j++;
  }
  for (long long cnt = 0; cnt < M / 3; cnt++) {
    for (long long i = 0; i < N; i++) {
      if (arr[i][j] != c2) return false;
    }
    j++;
  }
  for (long long cnt = 0; cnt < M / 3; cnt++) {
    for (long long i = 0; i < N; i++) {
      if (arr[i][j] != c3) return false;
    }
    j++;
  }
  return true;
}
void solve() {
  cin >> N >> M;
  read(arr, N, M);
  vector<char> c = {'R', 'B', 'G'};
  for (long long i = 0; i < 3; i++) {
    for (long long j = 0; j < 3; j++) {
      for (long long k = 0; k < 3; k++) {
        if (c[i] != c[j] and c[j] != c[k] and c[i] != c[k]) {
          if (row(c[i], c[j], c[k]) or col(c[i], c[j], c[k])) {
            cout << "YES" << '\n';
            return;
          }
        }
      }
    }
  }
  cout << "NO" << '\n';
}
signed main() {
  bool testcases = 0;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (testcases) {
    long long tt;
    cin >> tt;
    while (tt--) solve();
  } else
    solve();
}
