#include <bits/stdc++.h>
using namespace std;
int res[24], arr[24];
int convert[6][24] = {{23, 1,  21, 3,  0,  5,  2,  7,  4,  9,  6,  11,
                       12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 22, 8},
                      {4,  1,  6,  3,  8,  5,  10, 7,  23, 9, 21, 11,
                       12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 22, 0},
                      {0, 1, 2,  3,  16, 17, 6,  7,  8,  9,  10, 11,
                       4, 5, 14, 15, 20, 21, 18, 19, 12, 13, 22, 23},
                      {0,  1,  2,  3,  12, 13, 6,  7,  8,  9,  10, 11,
                       20, 21, 14, 15, 4,  5,  18, 19, 16, 17, 22, 23},
                      {17, 19, 2, 3,  4,  5,  6,  7,  8,  9,  12, 14,
                       1,  13, 0, 15, 16, 11, 18, 10, 20, 21, 22, 23},
                      {14, 12, 2,  3,  4,  5, 6,  7, 8,  9,  19, 17,
                       10, 13, 11, 15, 16, 0, 18, 1, 20, 21, 22, 23}};
bool check() {
  for (int i = 0; i < 24; i += 4) {
    if (!((res[i] == res[i + 1]) && (res[i + 1] == res[i + 2]) &&
          (res[i + 2] == res[i + 3]))) {
      return false;
    }
  }
  return true;
}
void tranform(int k) {
  for (int i = 0; i < 24; i++) {
    res[i] = arr[convert[k][i]];
  }
}
int main() {
  for (int i = 0; i < 24; i++) {
    cin >> arr[i];
  }
  bool flag = false;
  for (int i = 0; i < 6; i++) {
    tranform(i);
    if ((flag = check())) {
      break;
    }
  }
  if (flag) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
