#include <bits/stdc++.h>
using namespace std;
int a[25];
void rotate(vector<int> t) {
  for (int j = 0; j < 2; j++) {
    int temp = a[t[0]];
    for (int i = 1; i < t.size(); i++) a[t[i - 1]] = a[t[i]];
    a[t.back()] = temp;
  }
}
void move(int type) {
  if (type == 0) rotate({1, 3, 5, 7, 9, 11, 24, 22});
  if (type == 1) rotate({2, 4, 6, 8, 10, 12, 23, 21});
  if (type == 2) rotate({9, 10, 19, 17, 4, 3, 14, 16});
  if (type == 3) rotate({11, 12, 20, 18, 2, 1, 13, 15});
  if (type == 4) rotate({13, 14, 5, 6, 17, 18, 21, 22});
  if (type == 5) rotate({15, 16, 7, 8, 19, 20, 23, 24});
}
bool ok(vector<int> q) {
  int cc = a[q[0]];
  for (int to : q)
    if (a[to] != cc) return 0;
  return 1;
}
bool check() {
  return ok({1, 2, 3, 4}) && ok({5, 6, 7, 8}) && ok({9, 10, 11, 12}) &&
         ok({13, 14, 15, 16}) && ok({21, 22, 23, 24});
}
int main() {
  int t;
  for (int i = 1; i <= 24; i++) cin >> a[i];
  int i;
  for (i = 0; i < 6; i++) {
    move(i);
    if (check()) {
      cout << "Yes" << endl;
      break;
    }
    move(i);
    move(i);
    if (check()) {
      cout << "Yes" << endl;
      break;
    }
    move(i);
  }
  if (i == 6) cout << "No" << endl;
  return 0;
}
