#include <bits/stdc++.h>
using namespace std;
int a[25], b[25], c[25];
void check() {
  for (int i = 0; i < 6; i++) {
    for (int j = i * 4 + 2; j <= i * 4 + 4; j++) {
      if (b[j] != b[j - 1]) {
        return;
      }
    }
  }
  cout << "YES";
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  for (int i = 1; i <= 24; i++) {
    cin >> a[i];
    b[i] = a[i];
    c[i] = a[i];
  }
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[6] = a[10];
    b[8] = a[12];
    b[2] = a[6];
    b[4] = a[8];
    b[10] = a[21];
    b[12] = a[23];
    b[21] = a[2];
    b[23] = a[4];
    if (j == 2) continue;
    check();
  }
  for (int i = 1; i <= 24; i++) b[i] = c[i];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[5] = a[9];
    b[7] = a[11];
    b[1] = a[5];
    b[3] = a[7];
    b[9] = a[22];
    b[11] = a[24];
    b[22] = a[1];
    b[24] = a[3];
    if (j == 2) continue;
    check();
  }
  for (int i = 1; i <= 24; i++) b[i] = c[i];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[13] = a[5];
    b[14] = a[6];
    b[5] = a[17];
    b[6] = a[18];
    b[17] = a[21];
    b[18] = a[22];
    b[21] = a[13];
    b[22] = a[14];
    if (j == 2) continue;
    check();
  }
  for (int i = 1; i <= 24; i++) b[i] = c[i];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[15] = a[7];
    b[16] = a[8];
    b[7] = a[19];
    b[8] = a[20];
    b[19] = a[23];
    b[20] = a[24];
    b[23] = a[15];
    b[24] = a[16];
    if (j == 2) continue;
    check();
  }
  for (int i = 1; i <= 24; i++) b[i] = c[i];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[3] = a[17];
    b[4] = a[19];
    b[17] = a[9];
    b[19] = a[10];
    b[9] = a[14];
    b[10] = a[16];
    b[14] = a[3];
    b[16] = a[4];
    if (j == 2) continue;
    check();
  }
  for (int i = 1; i <= 24; i++) b[i] = c[i];
  for (int j = 1; j <= 3; j++) {
    for (int i = 1; i <= 24; i++) a[i] = b[i];
    b[1] = a[18];
    b[2] = a[20];
    b[18] = a[11];
    b[20] = a[12];
    b[11] = a[13];
    b[12] = a[15];
    b[13] = a[1];
    b[15] = a[2];
    if (j == 2) continue;
    check();
  }
  cout << "NO";
}
