#include <bits/stdc++.h>
using namespace std;
int a[30];
bool ok() {
  for (int i = 1; i <= 24; i += 4) {
    for (int j = 0; j < 4; j++) {
      if (a[i] != a[i + j]) return false;
    }
  }
  return true;
}
void L() {
  int x = a[1];
  a[1] = a[5];
  a[5] = a[9];
  a[9] = a[24];
  a[24] = x;
  x = a[3];
  a[3] = a[7];
  a[7] = a[11];
  a[11] = a[22];
  a[22] = x;
  x = a[13];
  a[13] = a[14];
  a[14] = a[16];
  a[16] = a[15];
  a[15] = x;
}
void Lb() {
  L();
  L();
  L();
}
void U() {
  int x = a[13];
  a[13] = a[5];
  a[5] = a[17];
  a[17] = a[21];
  a[21] = x;
  x = a[14];
  a[14] = a[6];
  a[6] = a[18];
  a[18] = a[22];
  a[22] = x;
  x = a[1];
  a[1] = a[3];
  a[3] = a[4];
  a[4] = a[2];
  a[2] = x;
}
void Ub() {
  U();
  U();
  U();
}
void F() {
  int x = a[3];
  a[3] = a[16];
  a[16] = a[10];
  a[10] = a[17];
  a[17] = x;
  x = a[4];
  a[4] = a[14];
  a[14] = a[9];
  a[9] = a[19];
  a[19] = x;
  x = a[5];
  a[5] = a[7];
  a[7] = a[8];
  a[8] = a[6];
  a[6] = x;
}
void Fb() {
  F();
  F();
  F();
}
bool can() {
  F();
  if (ok()) return true;
  Fb();
  Fb();
  if (ok()) return true;
  F();
  L();
  if (ok()) return true;
  Lb();
  Lb();
  if (ok()) return true;
  L();
  U();
  if (ok()) return true;
  Ub();
  Ub();
  if (ok()) return true;
  U();
  return false;
}
int main() {
  for (int i = 1; i <= 24; i++) {
    cin >> a[i];
  }
  cout << (can() ? "YES" : "NO");
}
