#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, int i) { return n & (1LL << i); }
inline long long setBit(long long n, int i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, int i) { return n & (~(1LL << i)); }
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
int a[26], b[26];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 1; i <= 24; ++i) cin >> a[i];
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[5] = a[1], b[7] = a[3], b[9] = a[5], b[11] = a[7], b[22] = a[11],
  b[24] = a[9], b[1] = a[24], b[3] = a[22];
  int cnt = 0;
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[1] = a[5], b[3] = a[7], b[5] = a[9], b[7] = a[11], b[9] = a[24],
  b[11] = a[22], b[24] = a[1], b[22] = a[3];
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[5] = a[17], b[6] = a[18], b[13] = a[5], b[14] = a[6], b[17] = a[21],
  b[18] = a[22], b[22] = a[14], b[21] = a[13];
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[6] = a[14], b[5] = a[13], b[18] = a[6], b[17] = a[5], b[22] = a[18],
  b[21] = a[17], b[14] = a[22], b[13] = a[21];
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[14] = a[4], b[16] = a[3], b[9] = a[14], b[10] = a[16], b[19] = a[9],
  b[17] = a[10], b[3] = a[17], b[4] = a[19];
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cnt = 0;
  for (int i = 1; i <= 24; ++i) {
    b[i] = a[i];
  }
  b[4] = a[14], b[3] = a[16], b[19] = a[4], b[17] = a[3], b[9] = a[19],
  b[10] = a[17], b[14] = a[9], b[16] = a[10];
  for (int i = 1; i <= 24; i += 4) {
    if (b[i] == b[i + 1] && b[i] == b[i + 2] && b[i] == b[i + 3]) ++cnt;
  }
  if (cnt == 6) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
