#include <bits/stdc++.h>
using namespace std;
int cube[25];
void u() {
  int vals[25];
  for (int i = 0; i < 24; i++) {
    vals[i] = cube[i];
  }
  cube[13] = vals[5];
  cube[14] = vals[6];
  cube[5] = vals[17];
  cube[6] = vals[18];
  cube[17] = vals[21];
  cube[18] = vals[22];
  cube[21] = vals[13];
  cube[22] = vals[14];
}
void l() {
  int vals[25];
  for (int i = 0; i < 24; i++) {
    vals[i] = cube[i];
  }
  cube[2] = vals[6];
  cube[4] = vals[8];
  cube[6] = vals[10];
  cube[8] = vals[12];
  cube[10] = vals[23];
  cube[12] = vals[21];
  cube[23] = vals[2];
  cube[21] = vals[4];
}
void f() {
  int vals[25];
  for (int i = 0; i <= 24; i++) {
    vals[i] = cube[i];
  }
  cube[3] = vals[17];
  cube[4] = vals[19];
  cube[17] = vals[10];
  cube[19] = vals[9];
  cube[10] = vals[16];
  cube[9] = vals[14];
  cube[16] = vals[3];
  cube[14] = vals[4];
}
bool isSolved() {
  for (int i = 1; i <= 24; i += 4) {
    if (cube[i] != cube[i + 1] || cube[i + 2] != cube[i + 3] ||
        cube[i] != cube[i + 2]) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 24; i++) {
    cin >> cube[i + 1];
  }
  f();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  f();
  f();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  f();
  l();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  l();
  l();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  l();
  u();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  u();
  u();
  if (isSolved()) {
    cout << "YES\n";
    return 0;
  }
  u();
  cout << "NO\n";
  return 0;
}
