#include <bits/stdc++.h>
using namespace std;
const long mod = 1e9 + 7;
int x[6] = {1, 2, 6, 3, 4, 5};
int cl[50], a[4][2][9], kt[100];
bool check(int i, int u, int v) {
  while (u <= 7) {
    int u1 = (u + 1) % 8;
    int v1 = (v + 1) % 8;
    if (cl[a[i][0][u]] == cl[a[i][1][v]] && cl[a[i][1][v]] == cl[a[i][1][v1]] &&
        cl[a[i][1][v1]] == cl[a[i][0][u1]]) {
      if (u == 6) return 1;
      u = (u + 2) % 8;
      v = (v + 2) % 8;
    } else {
      return 0;
    }
  }
}
void input() {
  for (int i = 1; i <= 24; ++i) {
    cin >> cl[i];
    int xx = x[(i - 1) / 4];
    if (kt[xx] == 0)
      kt[xx] = cl[i];
    else if (kt[xx] != cl[i])
      kt[xx] = -1;
  }
  a[1][0][0] = 13;
  a[1][0][1] = 14;
  a[1][0][2] = 5;
  a[1][0][3] = 6;
  a[1][0][4] = 17;
  a[1][0][5] = 18;
  a[1][0][6] = 21;
  a[1][0][7] = 22;
  a[1][1][0] = 15;
  a[1][1][1] = 16;
  a[1][1][2] = 7;
  a[1][1][3] = 8;
  a[1][1][4] = 19;
  a[1][1][5] = 20;
  a[1][1][6] = 23;
  a[1][1][7] = 24;
  a[2][0][0] = 1;
  a[2][0][1] = 2;
  a[2][0][2] = 18;
  a[2][0][3] = 20;
  a[2][0][4] = 12;
  a[2][0][5] = 11;
  a[2][0][6] = 15;
  a[2][0][7] = 13;
  a[2][1][0] = 3;
  a[2][1][1] = 4;
  a[2][1][2] = 17;
  a[2][1][3] = 19;
  a[2][1][4] = 10;
  a[2][1][5] = 9;
  a[2][1][6] = 16;
  a[2][1][7] = 14;
  a[3][0][0] = 23;
  a[3][0][1] = 21;
  a[3][0][2] = 2;
  a[3][0][3] = 4;
  a[3][0][4] = 6;
  a[3][0][5] = 8;
  a[3][0][6] = 10;
  a[3][0][7] = 12;
  a[3][1][0] = 24;
  a[3][1][1] = 22;
  a[3][1][2] = 1;
  a[3][1][3] = 3;
  a[3][1][4] = 5;
  a[3][1][5] = 7;
  a[3][1][6] = 9;
  a[3][1][7] = 11;
  for (int i = 1; i <= 3; ++i)
    if (kt[i] != -1 && kt[7 - i] != -1) {
      if (check(i, 0, 6) == 1 || check(i, 0, 2) == 1) {
        cout << "YES";
        return;
      }
    }
  cout << "NO";
}
void output() {}
int main() {
  input();
  output();
  return 0;
}
