#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(7) << fixed;
  vector<long long> v(24);
  for (long long i = 0; i < 24; i++) cin >> v[i];
  bool cu = 0;
  {
    vector<long long> vv{1, 3, 5, 7, 9, 11, 22, 24};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 0;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 0;
  }
  {
    vector<long long> vv{2, 4, 6, 8, 10, 12, 21, 23};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
  }
  {
    vector<long long> vv{13, 14, 5, 6, 17, 18, 21, 22};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
  }
  {
    vector<long long> vv{15, 16, 7, 8, 19, 20, 23, 24};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
  }
  {
    vector<long long> vv{11, 12, 20, 18, 2, 1, 13, 15};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
  }
  {
    vector<long long> vv{9, 10, 18, 17, 4, 3, 14, 16};
    vector<long long> ans[2];
    long long a = 6, b = 2;
    for (long long i = 0; i < 8; ++i) {
      ans[0].push_back(v[vv[a++ % 8] - 1]);
      ans[1].push_back(v[vv[b++ % 8] - 1]);
    }
    vector<long long> tem = v;
    for (long long i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[0][i];
    long long i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
    tem = v;
    for (i = 0; i < 8; ++i) tem[vv[i] - 1] = ans[1][i];
    i = 0;
    for (i = 0; i < 24; i += 4) {
      if (!(tem[i] == tem[i + 1] && tem[i + 1] == tem[i + 2] &&
            tem[i + 2] == tem[i + 3]))
        break;
    }
    if (i == 24) cu = 1;
  }
  if (cu)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
