#include <bits/stdc++.h>
using namespace std;
int a[24];
void rot(int i) {
  int c[6][8] = {
      {2, 4, 6, 8, 10, 12, 23, 21},   {1, 3, 5, 7, 9, 11, 24, 22},
      {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 temp = a[c[i][0] - 1];
  int temp2 = a[c[i][1] - 1];
  for (int j = 0; j < 5; j += 2) {
    a[c[i][j] - 1] = a[c[i][j + 2] - 1];
    a[c[i][j + 1] - 1] = a[c[i][j + 3] - 1];
  }
  a[c[i][6] - 1] = temp;
  a[c[i][7] - 1] = temp2;
}
int check() {
  int flag = 1;
  for (int i = 0; i < 23; i += 4) {
    if (a[i + 1] != a[i]) flag = 0;
    if (a[i + 2] != a[i]) flag = 0;
    if (a[i + 3] != a[i]) flag = 0;
  }
  return flag;
}
int main() {
  int flag = 0;
  for (int i = 0; i < 24; i++) cin >> a[i];
  for (int i = 0; i < 6; i++) {
    rot(i);
    flag = check();
    if (flag) break;
    rot(i);
    rot(i);
    flag = check();
    if (flag) break;
    rot(i);
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
}
