#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 1007681537;
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
struct myhash {
  int operator()(const vector<int>& v) const {
    long long res = 0;
    for (int x : v) {
      res = res * 6;
      res += x - 1;
    }
    return res;
  }
};
unordered_map<vector<int>, int, myhash> hs;
vector<int> ar(24);
int sq[6][8] = {
    {1, 3, 5, 7, 9, 11, 24, 22},    {2, 4, 6, 8, 10, 12, 23, 21},
    {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24},
    {3, 4, 17, 19, 10, 9, 16, 14},  {1, 2, 18, 20, 12, 11, 15, 13},
};
int sq2[6][4] = {
    {13, 14, 16, 15}, {18, 17, 19, 20}, {3, 4, 2, 1},
    {9, 10, 12, 11},  {5, 6, 8, 7},     {22, 21, 23, 24},
};
vector<int> rotate(vector<int>& ar, int ix) {
  vector<int> res = ar;
  for (int i = (0); i < (8); i++) {
    int j = (i + 2) % 8;
    res[sq[ix][i] - 1] = ar[sq[ix][j] - 1];
  }
  for (int i = (0); i < (4); i++) {
    int j = (i + 1) % 4;
    res[sq2[ix][i] - 1] = ar[sq2[ix][j] - 1];
  }
  return res;
}
vector<int> normalize(vector<int> ar) {
  map<int, int> tmp;
  vector<int> res;
  for (int i = (0); i < (int((ar).size())); i++) {
    if (!tmp.count(ar[i])) {
      int id = int((tmp).size());
      res.push_back(id);
      tmp[ar[i]] = id;
    } else {
      res.push_back(tmp[ar[i]]);
    }
  }
  return res;
}
void solve() {
  for (int i = (0); i < (24); i++) ar[i] = i / 4;
  queue<vector<int> > que;
  que.push(ar);
  while (int((que).size())) {
    vector<int> ar = que.front();
    que.pop();
    for (int i = (0); i < (6); i++) {
      vector<int> nar = rotate(ar, i);
      nar = normalize(nar);
      if (!hs[nar]) {
        hs[nar] = 1, que.push(nar);
      }
    }
    break;
  }
  vector<int> res(24);
  for (int i = (0); i < (24); i++) cin >> res[i];
  res = normalize(res);
  for (__typeof((hs).begin()) it = (hs).begin(); it != (hs).end(); it++) {
    vector<int> tmp = it->first;
    int found = 0;
    for (int i = (0); i < (24); i++)
      for (int j = (i + 1); j < (24); j++) {
        if (tmp[i] == tmp[j] && res[i] != res[j]) {
          found = 1;
          break;
        }
      }
    if (!found) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int JUDGE_ONLINE = 1;
  if (argc > 1) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    JUDGE_ONLINE = 0;
    assert(freopen(argv[2], "wb", stdout));
  }
  solve();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
