#include <bits/stdc++.h>
using namespace std;
int a[8][8];
int b[8][8];
void refresh() {
  for (int i = 1; i <= 6; i++) {
    for (int j = 1; j <= 4; j++) {
      b[i][j] = a[i][j];
    }
  }
}
bool check() {
  for (int i = 1; i <= 6; i++) {
    for (int j = 2; j <= 4; j++) {
      if (b[i][j] != b[i][j - 1]) {
        return false;
      }
    }
  }
  return true;
}
int main() {
  for (int i = 1; i <= 4; i++) {
    cin >> a[1][i];
  }
  for (int i = 1; i <= 4; i++) {
    cin >> a[2][i];
  }
  for (int i = 1; i <= 4; i++) {
    cin >> a[3][i];
  }
  cin >> a[5][2] >> a[5][4] >> a[5][1] >> a[5][3];
  cin >> a[6][3] >> a[6][1] >> a[6][4] >> a[6][2];
  cin >> a[4][4] >> a[4][3] >> a[4][2] >> a[4][1];
  refresh();
  int i = b[5][2];
  int j = b[5][4];
  b[5][2] = b[2][1];
  b[5][4] = b[2][2];
  b[2][1] = b[6][3];
  b[2][2] = b[6][1];
  b[6][3] = b[4][4];
  b[6][1] = b[4][3];
  b[4][4] = i;
  b[4][3] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  refresh();
  b[5][2] = b[4][4];
  b[5][4] = b[4][3];
  b[4][4] = b[6][3];
  b[4][3] = b[6][1];
  b[6][3] = b[2][1];
  b[6][1] = b[2][2];
  b[2][1] = i;
  b[2][2] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  refresh();
  i = b[1][3];
  j = b[1][4];
  b[1][3] = b[6][3];
  b[1][4] = b[6][4];
  b[6][3] = b[3][2];
  b[6][4] = b[3][1];
  b[3][2] = b[5][3];
  b[3][1] = b[5][4];
  b[5][3] = i;
  b[5][4] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  refresh();
  b[1][3] = b[5][3];
  b[1][4] = b[5][4];
  b[5][3] = b[3][2];
  b[5][4] = b[3][1];
  b[3][2] = b[6][3];
  b[3][1] = b[6][4];
  b[6][3] = i;
  b[6][4] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  refresh();
  i = b[1][1];
  j = b[1][3];
  b[1][1] = b[2][1];
  b[1][3] = b[2][3];
  b[2][1] = b[3][1];
  b[2][3] = b[3][3];
  b[3][1] = b[4][1];
  b[3][3] = b[4][3];
  b[4][1] = i;
  b[4][3] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  refresh();
  b[1][1] = b[4][1];
  b[1][3] = b[4][3];
  b[4][1] = b[3][1];
  b[4][3] = b[3][3];
  b[3][1] = b[2][1];
  b[3][3] = b[2][3];
  b[2][1] = i;
  b[2][3] = j;
  if (check()) {
    printf("YES\n");
    return 0;
  }
  printf("NO\n");
  return 0;
}
