#include <bits/stdc++.h>
using namespace std;
int color[25];
bool check_face_solved(int st) {
  for (long long int i = st + 1; i <= st + 3; i++) {
    if (color[i] != color[st]) {
      return false;
    }
  }
  return true;
}
bool can_rotate_dir(int arr[2][8], int rot) {
  for (long long int i = 0; i <= 4 - 1; i++) {
    for (long long int j = 0; j <= 2 - 1; j++) {
      if (color[arr[j][2 * i]] != color[arr[j][2 * i + 1]]) {
        return false;
      }
    }
  }
  for (long long int i = 0; i <= 8 - 1; i++) {
    if (color[arr[0][i]] != color[arr[1][(i + rot + 8) % 8]]) return false;
  }
  return true;
}
bool can_rotate(int arr[2][8]) {
  return can_rotate_dir(arr, 2) || can_rotate_dir(arr, -2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int t;
  string ans = "NO";
  for (long long int i = 1; i <= 24; i++) {
    cin >> color[i];
  }
  if (check_face_solved(1) && check_face_solved(9)) {
    int arr[2][8] = {{13, 14, 5, 6, 17, 18, 21, 22},
                     {15, 16, 7, 8, 19, 20, 23, 24}};
    if (can_rotate(arr)) ans = "YES";
  } else if (check_face_solved(13) && check_face_solved(17)) {
    int arr[2][8] = {{1, 3, 5, 7, 9, 11, 22, 24}, {2, 4, 6, 8, 10, 12, 21, 23}};
    if (can_rotate(arr)) ans = "YES";
  } else if (check_face_solved(5) && check_face_solved(21)) {
    int arr[2][8] = {{3, 4, 17, 19, 10, 9, 16, 14},
                     {1, 2, 18, 20, 12, 11, 15, 13}};
    if (can_rotate(arr)) ans = "YES";
  }
  cout << ans;
  return 0;
}
