#include <bits/stdc++.h>
using namespace std;
int arr[25];
int arr2[25];
void copy(int (&arr)[25], int (&arr2)[25]) {
  for (int i = 1; i <= 24; i++) {
    arr2[i] = arr[i];
  }
}
void tulis(int arr[]) {
  for (int i = 1; i <= 24; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
}
bool check(int arr[]) {
  bool found = true;
  int k = 1;
  while (k <= 21) {
    int x = arr[k];
    for (int i = 0; i < 4; i++) {
      if (arr[i + k] != x) {
        found = false;
      }
      if (!found) {
        break;
      }
    }
    if (!found) {
      break;
    }
    k += 4;
  }
  return found;
}
int main() {
  for (int i = 1; i <= 24; i++) {
    cin >> arr[i];
  }
  int k = 1;
  int j = 1;
  int sama[7];
  while (k <= 21) {
    int beda = 0;
    int x;
    x = arr[k];
    for (int i = 0; i < 4; i++) {
      if (arr[i + k] != x) {
        beda++;
        break;
      }
      if (i == 3) {
        sama[j] = k / 4 + 1;
        j++;
      }
    }
    k += 4;
  }
  j--;
  if (j != 2) {
    cout << "NO\n";
    return 0;
  } else {
    for (int i = 1; i <= 2; i++) {
      if (sama[i] == 1) {
        copy(arr, arr2);
        arr2[21] = arr[17];
        arr2[22] = arr[18];
        arr2[13] = arr[21];
        arr2[14] = arr[22];
        arr2[5] = arr[13];
        arr2[6] = arr[14];
        arr2[17] = arr[5];
        arr2[18] = arr[6];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[21] = arr[13];
        arr2[22] = arr[14];
        arr2[13] = arr[5];
        arr2[14] = arr[6];
        arr2[5] = arr[17];
        arr2[6] = arr[18];
        arr2[17] = arr[21];
        arr2[18] = arr[22];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
      if (sama[i] == 2) {
        copy(arr, arr2);
        arr2[3] = arr[17];
        arr2[4] = arr[19];
        arr2[17] = arr[10];
        arr2[19] = arr[9];
        arr2[10] = arr[14];
        arr2[9] = arr[16];
        arr2[16] = arr[3];
        arr2[14] = arr[4];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[3] = arr[14];
        arr2[4] = arr[16];
        arr2[17] = arr[3];
        arr2[19] = arr[4];
        arr2[10] = arr[17];
        arr2[9] = arr[19];
        arr2[14] = arr[10];
        arr2[16] = arr[9];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
      if (sama[i] == 3) {
        copy(arr, arr2);
        arr2[7] = arr[15];
        arr2[8] = arr[16];
        arr2[19] = arr[7];
        arr2[20] = arr[8];
        arr2[23] = arr[19];
        arr2[24] = arr[20];
        arr2[15] = arr[23];
        arr2[16] = arr[24];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[7] = arr[19];
        arr2[8] = arr[20];
        arr2[19] = arr[23];
        arr2[20] = arr[24];
        arr2[23] = arr[15];
        arr2[24] = arr[16];
        arr2[15] = arr[7];
        arr2[16] = arr[8];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
      if (sama[i] == 4) {
        copy(arr, arr2);
        arr2[1] = arr[5];
        arr2[3] = arr[7];
        arr2[5] = arr[9];
        arr2[7] = arr[11];
        arr2[9] = arr[24];
        arr2[11] = arr[22];
        arr2[24] = arr[1];
        arr2[22] = arr[3];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[1] = arr[24];
        arr2[3] = arr[22];
        arr2[5] = arr[1];
        arr2[7] = arr[3];
        arr2[9] = arr[5];
        arr2[11] = arr[7];
        arr2[24] = arr[9];
        arr2[22] = arr[11];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
      if (sama[i] == 5) {
        copy(arr, arr2);
        arr2[2] = arr[6];
        arr2[4] = arr[8];
        arr2[6] = arr[10];
        arr2[8] = arr[12];
        arr2[10] = arr[23];
        arr2[12] = arr[21];
        arr2[23] = arr[2];
        arr2[21] = arr[4];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[2] = arr[23];
        arr2[4] = arr[21];
        arr2[6] = arr[2];
        arr2[8] = arr[4];
        arr2[10] = arr[6];
        arr2[12] = arr[8];
        arr2[23] = arr[10];
        arr2[21] = arr[12];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
      if (sama[i] == 6) {
        copy(arr, arr2);
        arr2[1] = arr[18];
        arr2[2] = arr[20];
        arr2[18] = arr[12];
        arr2[20] = arr[11];
        arr2[12] = arr[15];
        arr2[11] = arr[13];
        arr2[15] = arr[1];
        arr2[13] = arr[2];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
        copy(arr, arr2);
        arr2[1] = arr[15];
        arr2[2] = arr[13];
        arr2[18] = arr[1];
        arr2[20] = arr[2];
        arr2[12] = arr[18];
        arr2[11] = arr[20];
        arr2[15] = arr[12];
        arr2[13] = arr[11];
        if (check(arr2)) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  cout << "NO\n";
  return 0;
}
