#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > rotations = {{0, 2, 4, 6, 8, 10, 23, 21},
                                  {14, 15, 6, 7, 18, 19, 22, 23},
                                  {15, 13, 2, 3, 16, 18, 9, 8}};
bool solve(vector<int> &V) {
  for (int i = 0; i < 6; ++i) {
    int ind = i * 4;
    if (V[ind] != V[ind + 1] || V[ind] != V[ind + 2] || V[ind] != V[ind + 3])
      return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<int> V(24);
  for (int i = 0; i < 24; ++i) cin >> V[i];
  for (int i = 0; i < 3; ++i) {
    for (int j = 1; j <= 3; ++j) {
      vector<int> aux = V;
      if (j == 2) continue;
      for (int k = 0; k < 8; ++k) {
        aux[rotations[i][k]] = V[rotations[i][(k + j * 2) % 8]];
      }
      if (solve(aux)) {
        cout << "YES\n";
        return 0;
      }
    }
  }
  cout << "NO\n";
  return 0;
}
