#include <bits/stdc++.h>
using namespace std;
void Copy(pair<int, int> a, pair<int, int> b, vector<int> &V) {
  V[b.first] = V[a.first];
  V[b.second] = V[a.second];
}
void Turn(pair<int, int> a, pair<int, int> b, pair<int, int> c,
          pair<int, int> d, vector<int> &V) {
  pair<int, int> t = make_pair(V[a.first], V[a.second]);
  Copy(b, a, V);
  Copy(c, b, V);
  Copy(d, c, V);
  V[d.first] = t.first;
  V[d.second] = t.second;
}
pair<int, int> edge(int a, char c) {
  a--;
  switch (c) {
    case 'u':
      return make_pair(4 * a + 1, 4 * a + 2);
    case 'd':
      return make_pair(4 * a + 4, 4 * a + 3);
    case 'r':
      return make_pair(4 * a + 2, 4 * a + 4);
    case 'l':
      return make_pair(4 * a + 3, 4 * a + 1);
  }
}
void F(vector<int> &a) {
  Turn(edge(1, 'd'), edge(5, 'l'), edge(3, 'u'), edge(4, 'r'), a);
}
void U(vector<int> &a) {
  Turn(edge(4, 'u'), edge(2, 'u'), edge(5, 'u'), edge(6, 'u'), a);
}
void R(vector<int> &a) {
  Turn(edge(1, 'r'), edge(2, 'r'), edge(3, 'r'), edge(6, 'l'), a);
}
bool solved(vector<int> a) {
  for (int i = 1; i < 25; i++) {
    if ((i - 1) % 4 != 0)
      if (a[i] != a[i - 1]) return false;
  }
  return true;
}
int main() {
  vector<int> a(25);
  for (int i = 1; i < 25; i++) cin >> a[i];
  U(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  U(a);
  U(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  U(a);
  R(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  R(a);
  R(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  R(a);
  F(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  F(a);
  F(a);
  if (solved(a)) {
    cout << "YES";
    return 0;
  }
  F(a);
  cout << "NO";
}
