#include <bits/stdc++.h>
using namespace std;
int a[30];
bool ok(int p, int b, int c, int d) {
  return a[p] == a[b] && a[p] == a[c] && a[p] == a[d];
}
int main() {
  for (int i = 1; i <= 24; i++) {
    cin >> a[i];
  }
  swap(a[21], a[22]);
  swap(a[23], a[24]);
  if (ok(13, 14, 15, 16) && ok(20, 17, 18, 19)) {
    if (ok(1, 3, 6, 8) && ok(2, 4, 23, 21) && ok(5, 7, 10, 12) &&
        ok(9, 11, 22, 24)) {
      cout << "YES" << endl;
      return 0;
    }
    if (ok(1, 3, 24, 22) && ok(2, 4, 5, 7) && ok(6, 8, 9, 11) &&
        ok(10, 12, 21, 23)) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  } else if (ok(1, 2, 3, 4) && ok(9, 10, 11, 12)) {
    if (ok(5, 6, 15, 16) && ok(7, 8, 17, 18) && ok(13, 14, 23, 24) &&
        ok(19, 20, 21, 22)) {
      cout << "YES" << endl;
      return 0;
    }
    if (ok(5, 6, 19, 20) && ok(7, 8, 13, 14) && ok(15, 16, 21, 22) &&
        ok(17, 18, 23, 24)) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  } else if (ok(5, 6, 7, 8) && ok(21, 22, 23, 24)) {
    if (ok(1, 2, 14, 16) && ok(3, 4, 18, 20) && ok(9, 10, 13, 15) &&
        ok(11, 12, 17, 19)) {
      cout << "YES" << endl;
      return 0;
    }
    if (ok(1, 2, 17, 19) && ok(3, 4, 13, 15) && ok(9, 10, 18, 20) &&
        ok(11, 12, 14, 16)) {
      cout << "YES" << endl;
      return 0;
    }
    cout << "NO" << endl;
    return 0;
  } else
    cout << "NO" << endl;
}
