#include <bits/stdc++.h>
using namespace std;
long long ar[24], b[24], n;
vector<vector<long long> > p(6);
bool check() {
  for (long long i = 1; i < 24; i += 4) {
    for (long long j = 1; j < 4; j++)
      if (ar[i] != ar[i + j]) return 0;
  }
  return 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  n = 24;
  for (long long i = 0; i < n; i++) {
    cin >> ar[i + 1];
    b[i + 1] = ar[i + 1];
  }
  p[4].push_back(3);
  p[4].push_back(4);
  p[4].push_back(17);
  p[4].push_back(19);
  p[4].push_back(10);
  p[4].push_back(9);
  p[4].push_back(16);
  p[4].push_back(14);
  p[5].push_back(1);
  p[5].push_back(2);
  p[5].push_back(18);
  p[5].push_back(20);
  p[5].push_back(12);
  p[5].push_back(11);
  p[5].push_back(15);
  p[5].push_back(13);
  p[0].push_back(1);
  p[0].push_back(3);
  p[0].push_back(5);
  p[0].push_back(7);
  p[0].push_back(9);
  p[0].push_back(11);
  p[0].push_back(24);
  p[0].push_back(22);
  p[1].push_back(2);
  p[1].push_back(4);
  p[1].push_back(6);
  p[1].push_back(8);
  p[1].push_back(10);
  p[1].push_back(12);
  p[1].push_back(23);
  p[1].push_back(21);
  p[2].push_back(13);
  p[2].push_back(14);
  p[2].push_back(5);
  p[2].push_back(6);
  p[2].push_back(17);
  p[2].push_back(18);
  p[2].push_back(21);
  p[2].push_back(22);
  p[3].push_back(15);
  p[3].push_back(16);
  p[3].push_back(7);
  p[3].push_back(8);
  p[3].push_back(19);
  p[3].push_back(20);
  p[3].push_back(23);
  p[3].push_back(24);
  vector<vector<long long> > path(6);
  for (long long i = 0; i < 6; i++)
    for (auto k : p[i]) path[i].push_back(k);
  for (long long i = 0; i < 6; i++) {
    for (long long l = 0; l < 24; l++) ar[l + 1] = b[l + 1];
    vector<long long> hello;
    for (long long j = 0; j < path[i].size(); j++)
      hello.push_back(ar[path[i][j]]);
    vector<long long> ne;
    for (long long j = 0; j < path[i].size(); j++) {
      long long k = (j + 2) % 8;
      ne.push_back(hello[k]);
    }
    for (long long j = 0; j < path[i].size(); j++) ar[path[i][j]] = ne[j];
    if (check()) {
      cout << "YES";
      return 0;
    }
    ne.clear();
    for (long long j = 0; j < path[i].size(); j++) {
      long long k = (j - 2);
      if (k < 0) k += 8;
      ne.push_back(hello[k]);
    }
    for (long long j = 0; j < path[i].size(); j++) ar[path[i][j]] = ne[j];
    if (check()) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
  return 0;
}
