#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e6 + 7;
int a[30], b[30], flag;
void solve(int i, int j, int k, int l, int n, int m, int u, int v) {
  for (int i = 1; i <= 24; i++) a[i] = b[i];
  swap(a[i], a[k]);
  swap(a[j], a[l]);
  swap(a[i], a[n]);
  swap(a[j], a[m]);
  swap(a[i], a[u]);
  swap(a[j], a[v]);
  for (int i = 1; i <= n; i += 4) {
    if (a[i] == a[i + 1] && a[i + 1] == a[i + 2] && a[i + 2] == a[i + 3])
      ;
    else
      return;
  }
  flag = 1;
}
int main() {
  for (int i = 1; i <= 24; i++) cin >> b[i];
  solve(10, 12, 6, 8, 2, 4, 21, 23);
  solve(10, 12, 21, 23, 2, 4, 6, 8);
  solve(9, 11, 5, 7, 1, 3, 22, 24);
  solve(9, 11, 22, 24, 1, 3, 5, 7);
  solve(5, 6, 17, 18, 21, 22, 13, 14);
  solve(5, 6, 13, 14, 21, 22, 17, 18);
  solve(7, 8, 19, 20, 23, 24, 15, 16);
  solve(7, 8, 15, 16, 23, 24, 19, 20);
  solve(1, 2, 18, 20, 11, 12, 13, 15);
  solve(1, 2, 13, 15, 11, 12, 18, 20);
  solve(3, 4, 17, 19, 9, 10, 14, 16);
  solve(3, 4, 14, 16, 9, 10, 17, 19);
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
