#include <bits/stdc++.h>
using namespace std;
vector<int> rubik(25);
bool chk(vector<int>& a) {
  for (int i = 0; i < 6; i++) {
    if (!(a[4 * i + 1] == a[4 * i + 2] && a[4 * i + 2] == a[4 * i + 3] &&
          a[4 * i + 3] == a[4 * i + 4]))
      return false;
  }
  return true;
}
int main() {
  int n = 24;
  for (int i = 1; i <= n; i++) {
    cin >> rubik[i];
  }
  int t[3][8] = {{2, 4, 6, 8, 10, 12, 23, 21},
                 {3, 4, 17, 19, 10, 9, 16, 14},
                 {13, 14, 5, 6, 17, 18, 21, 22}};
  bool possible = false;
  for (int i = 0; i < 3; i++) {
    vector<int> a = rubik;
    for (int j = 0; j < 8; j++) {
      a[t[i][j]] = rubik[t[i][(j + 2) % 8]];
    }
    if (chk(a)) {
      possible = true;
      break;
    }
    a = rubik;
    for (int j = 0; j < 8; j++) {
      a[t[i][j]] = rubik[t[i][(j + 6) % 8]];
    }
    if (chk(a)) {
      possible = true;
      break;
    }
  }
  if (possible) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }
  return 0;
}
