#include <bits/stdc++.h>
using namespace std;
int a[25];
void rot13(int x) {
  if (x == 1) {
    swap(a[1], a[22]);
    swap(a[3], a[24]);
    swap(a[22], a[5]);
    swap(a[24], a[7]);
    swap(a[22], a[9]);
    swap(a[24], a[11]);
  }
}
void rot5(int x) {
  if (x == 1) {
    swap(a[3], a[16]);
    swap(a[4], a[14]);
    swap(a[3], a[10]);
    swap(a[4], a[9]);
    swap(a[3], a[17]);
    swap(a[4], a[19]);
  }
}
void rot1(int x) {
  if (x == 1) {
    swap(a[5], a[17]);
    swap(a[6], a[18]);
    swap(a[5], a[21]);
    swap(a[6], a[22]);
    swap(a[5], a[14]);
    swap(a[6], a[13]);
  }
}
void print() {
  for (int i = 1; i <= 24; i++) cout << a[i] << " ";
  cout << "\n";
}
bool cek() {
  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])
      continue;
    else
      return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (int i = 1; i <= 24; i++) cin >> a[i];
  bool bol = 0;
  rot13(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot13(1);
  rot13(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot13(1);
  rot5(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot5(1);
  rot5(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot5(1);
  rot1(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot1(1);
  rot1(1);
  if (cek()) cout << "YES\n", bol = 1;
  rot1(1);
  if (!bol) cout << "NO\n";
  return 0;
}
