#include <bits/stdc++.h>
using namespace std;
int main() {
  int v[6][4];
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) cin >> v[i][j];
  }
  int cnt1 = 0, cnt2 = 0, cnt3 = 0;
  for (int i = 0; i < 3; i++)
    if (v[0][i] == v[0][i + 1] && v[2][i] == v[2][i + 1]) cnt1++;
  for (int i = 0; i < 3; i++)
    if (v[1][i] == v[1][i + 1] && v[5][i] == v[5][i + 1]) cnt2++;
  for (int i = 0; i < 3; i++)
    if (v[3][i] == v[3][i + 1] && v[4][i] == v[4][i + 1]) cnt3++;
  vector<int> a;
  a.push_back(0);
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 4; j++) a.push_back(v[i][j]);
  }
  if (cnt1 == 3 && cnt2 != 3 && cnt3 != 3) {
    if (a[5] == a[6] && a[7] == a[8] && a[17] == a[18] && a[19] == a[20] &&
        a[21] == a[22] && a[23] == a[24] && a[13] == a[14] && a[15] == a[16]) {
      if (a[5] == a[15]) {
        if (a[13] == a[23] && a[21] == a[19] && a[17] == a[7])
          cout << "YES";
        else
          cout << "NO";
      } else if (a[5] == a[19]) {
        if (a[13] == a[7] && a[17] == a[23] && a[21] == a[15])
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else
      cout << "NO";
  } else if (cnt1 != 3 && cnt2 == 3 && cnt3 != 3) {
    if (a[1] == a[2] && a[3] == a[4] && a[18] == a[20] && a[17] == a[19] &&
        a[11] == a[12] && a[9] == a[10] && a[15] == a[13] && a[16] == a[14]) {
      if (a[1] == a[17]) {
        if (a[18] == a[9] && a[11] == a[16] && a[15] == a[3])
          cout << "YES";
        else
          cout << "NO";
      } else if (a[1] == a[16]) {
        if (a[18] == a[3] && a[11] == a[17] && a[15] == a[9])
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else
      cout << "NO";
  } else if (cnt1 != 3 && cnt2 != 3 && cnt3 == 3) {
    if (a[1] == a[3] && a[2] == a[4] && a[5] == a[7] && a[6] == a[8] &&
        a[9] == a[11] && a[10] == a[12] && a[24] == a[22] && a[23] == a[21]) {
      if (a[1] == a[6]) {
        if (a[5] == a[10] && a[9] == a[23] && a[24] == a[2])
          cout << "YES";
        else
          cout << "NO";
      } else if (a[1] == a[23]) {
        if (a[5] == a[2] && a[9] == a[6] && a[24] == a[10])
          cout << "YES";
        else
          cout << "NO";
      } else
        cout << "NO";
    } else
      cout << "NO";
  } else
    cout << "NO";
  return 0;
}
