#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int sz = 1e6 + 10;
int ar[26];
int f1[] = {1, 3, 5, 7, 9, 11, 22, 24};
int f2[] = {2, 4, 6, 8, 10, 12, 21, 23};
int f3[] = {15, 16, 7, 8, 19, 20, 23, 24};
int f4[] = {13, 14, 5, 6, 17, 18, 21, 22};
int f5[] = {3, 4, 17, 19, 10, 9, 16, 14};
int f6[] = {1, 2, 18, 20, 12, 11, 15, 13};
bool check() {
  set<int> st;
  for (int i = 1; i < 25; i += 4) {
    st.clear();
    st.insert(ar[i + 0]);
    st.insert(ar[i + 1]);
    st.insert(ar[i + 2]);
    st.insert(ar[i + 3]);
    if (st.size() != 1) return false;
  }
  return true;
}
bool valid() {
  vector<int> val;
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f1[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f1[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f1[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f1[i]] = val[i];
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f2[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f2[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f2[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f2[i]] = val[i];
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f3[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f3[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f3[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f3[i]] = val[i];
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f4[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f4[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f4[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f4[i]] = val[i];
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f5[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f5[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f5[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f5[i]] = val[i];
  val.clear();
  for (int i = 0; i < 8; i++) val.push_back(ar[f6[i]]);
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f6[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 4);
  reverse(val.begin() + 4, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f6[i]] = val[i];
  if (check()) return true;
  reverse(val.begin(), val.begin() + 2);
  reverse(val.begin() + 2, val.end());
  reverse(val.begin(), val.end());
  for (int i = 0; i < 8; i++) ar[f6[i]] = val[i];
  return false;
}
int main() {
  while (cin >> ar[1]) {
    for (int i = 2; i <= 24; i++) cin >> ar[i];
    puts(valid() ? "YES" : "NO");
  }
  return 0;
}
