#include <bits/stdc++.h>
using namespace std;
int a[10][10];
int b[10];
int main() {
  int k = 0;
  for (int i = 1; i <= 6; i++) {
    for (int j = 1; j <= 4; j++) {
      cin >> a[i][j];
    }
  }
  swap(a[6][1], a[6][2]);
  swap(a[6][3], a[6][4]);
  for (int i = 1; i <= 6; i++) {
    if (a[i][1] == a[i][2] && a[i][1] == a[i][3] && a[i][1] == a[i][4]) {
      b[k++] = i;
    }
  }
  if (k != 2) {
    cout << "NO" << endl;
    return 0;
  } else {
    if (!((b[0] == 1 && b[1] == 3) || (b[0] == 4 && b[1] == 5) ||
          (b[0] == 2 && b[1] == 6))) {
      cout << "NO" << endl;
      return 0;
    }
    if (b[0] == 1 && b[1] == 3) {
      for (int i = 1; i <= 6; i++) {
        if (i != 1 && i != 3) {
          if (a[i][1] != a[i][2] || a[i][3] != a[i][4]) {
            cout << "NO" << endl;
            return 0;
          }
        }
      }
      if (a[2][1] == a[4][3] && a[2][3] == a[5][1] && a[5][3] == a[6][1] &&
          a[6][3] == a[4][1]) {
        cout << "YES" << endl;
        return 0;
      } else if (a[2][1] == a[5][3] && a[2][3] == a[4][1] &&
                 a[4][3] == a[6][1] && a[6][3] == a[5][1]) {
        cout << "YES" << endl;
        return 0;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    } else if (b[0] == 2 && b[1] == 6) {
      for (int i = 1; i <= 6; i++) {
        if (i != 2 && i != 6 && i != 4 && i != 5) {
          if (a[i][1] != a[i][2] || a[i][3] != a[i][4]) {
            cout << i << "NO" << endl;
            return 0;
          }
        }
        if (i == 4 || i == 5) {
          if (a[i][1] != a[i][3] || a[i][2] != a[i][4]) {
            cout << "NO" << endl;
            return 0;
          }
        }
      }
      if (a[1][1] == a[5][3] && a[3][1] == a[5][2] && a[3][3] == a[4][4] &&
          a[1][3] == a[4][1]) {
        cout << "YES" << endl;
        return 0;
      } else if (a[1][1] == a[4][2] && a[3][1] == a[4][3] &&
                 a[3][3] == a[5][3] && a[1][3] == a[5][2]) {
        cout << "YES" << endl;
        return 0;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    } else {
      for (int i = 1; i <= 6; i++) {
        if (i != 4 && i != 5) {
          if (a[i][1] != a[i][3] || a[i][2] != a[i][4]) {
            cout << "NO" << endl;
            return 0;
          }
        }
      }
      if (a[1][1] == a[2][2] && a[2][1] == a[3][2] && a[3][1] == a[6][2] &&
          a[1][2] == a[6][1]) {
        cout << "YES" << endl;
        return 0;
      } else if (a[1][2] == a[2][1] && a[2][2] == a[3][1] &&
                 a[3][2] == a[6][1] && a[6][2] == a[1][1]) {
        cout << "YES" << endl;
        return 0;
      } else {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
}
