#include <bits/stdc++.h>
int a[25];
using namespace std;
int main() {
  for (int i = 1; i <= 24; i++) cin >> a[i];
  int m[7] = {0};
  int pos[2] = {0};
  int sl = 0;
  for (int i = 1; i <= 6; i++)
    if (a[(i - 1) * 4 + 4] == a[(i - 1) * 4 + 1] &&
        a[(i - 1) * 4 + 1] == a[(i - 1) * 4 + 2] &&
        a[(i - 1) * 4 + 2] == a[(i - 1) * 4 + 3]) {
      sl++;
      m[i] = 1;
      if (sl == 1)
        pos[0] = i;
      else
        pos[1] = i;
    }
  if (sl != 2)
    cout << "NO";
  else {
    if (pos[0] == 1 && pos[1] == 3) {
      bool res1 = true;
      res1 = res1 and (a[13] == a[14]);
      res1 = res1 and (a[5] == a[6]);
      res1 = res1 and (a[15] == a[16]);
      res1 = res1 and (a[7] == a[8]);
      res1 = res1 and (a[17] == a[18]);
      res1 = res1 and (a[19] == a[20]);
      res1 = res1 and (a[21] == a[22]);
      res1 = res1 and (a[23] == a[24]);
      if (res1) {
        res1 = res1 and (a[13] == a[23]);
        res1 = res1 and (a[5] == a[15]);
        res1 = res1 and (a[17] == a[7]);
        res1 = res1 and (a[21] == a[19]);
        bool res2 = true;
        res2 = res2 and (a[13] == a[7]);
        res2 = res2 and (a[5] == a[19]);
        res2 = res2 and (a[17] == a[23]);
        res2 = res2 and (a[21] == a[15]);
        if (res1 || res2)
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else if (pos[0] == 4 && pos[1] == 5) {
      bool res1 = true;
      res1 = res1 and (a[24] == a[22]);
      res1 = res1 and (a[23] == a[21]);
      res1 = res1 and (a[1] == a[3]);
      res1 = res1 and (a[2] == a[4]);
      res1 = res1 and (a[5] == a[7]);
      res1 = res1 and (a[6] == a[8]);
      res1 = res1 and (a[9] == a[11]);
      res1 = res1 and (a[10] == a[12]);
      if (res1) {
        res1 = res1 and (a[24] == a[2]);
        res1 = res1 and (a[1] == a[6]);
        res1 = res1 and (a[5] == a[10]);
        res1 = res1 and (a[9] == a[23]);
        bool res2 = true;
        res2 = res2 and (a[24] == a[10]);
        res2 = res2 and (a[1] == a[23]);
        res2 = res2 and (a[5] == a[2]);
        res2 = res2 and (a[9] == a[6]);
        if (res1 || res2)
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else if (pos[0] == 2 && pos[1] == 6) {
      bool res1 = true;
      res1 = res1 and (a[16] == a[14]);
      res1 = res1 and (a[15] == a[13]);
      res1 = res1 and (a[4] == a[3]);
      res1 = res1 and (a[1] == a[2]);
      res1 = res1 and (a[17] == a[19]);
      res1 = res1 and (a[18] == a[20]);
      res1 = res1 and (a[10] == a[9]);
      res1 = res1 and (a[11] == a[12]);
      if (res1) {
        res1 = res1 and (a[16] == a[1]);
        res1 = res1 and (a[3] == a[18]);
        res1 = res1 and (a[17] == a[12]);
        res1 = res1 and (a[10] == a[15]);
        bool res2 = true;
        res2 = res2 and (a[16] == a[12]);
        res2 = res2 and (a[3] == a[15]);
        res2 = res2 and (a[17] == a[1]);
        res2 = res2 and (a[10] == a[18]);
        if (res1 || res2)
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else
      cout << "NO";
  }
}
