#include <bits/stdc++.h>
using namespace std;
void swap(int *a, int *b) {
  int c = *a;
  *a = *b;
  *b = c;
}
int arr[25];
bool check(int freq[]) {
  int i;
  int cur;
  for (i = 1; i <= 24; i++) {
    if (i % 4 == 1) {
      cur = freq[i];
    } else {
      if (freq[i] != cur) return false;
    }
  }
  return true;
}
int main() {
  int i, j;
  for (i = 1; i <= 24; i++) {
    cin >> arr[i];
  }
  vector<pair<int, int> > vec[6];
  vec[0].push_back(make_pair(5, 6));
  vec[0].push_back(make_pair(13, 14));
  vec[0].push_back(make_pair(21, 2));
  vec[0].push_back(make_pair(17, 18));
  vec[1].push_back(make_pair(3, 4));
  vec[1].push_back(make_pair(17, 19));
  vec[1].push_back(make_pair(10, 9));
  vec[1].push_back(make_pair(16, 14));
  vec[2].push_back(make_pair(1, 3));
  vec[2].push_back(make_pair(5, 7));
  vec[2].push_back(make_pair(9, 11));
  vec[2].push_back(make_pair(24, 22));
  vec[3].push_back(make_pair(15, 16));
  vec[3].push_back(make_pair(7, 8));
  vec[3].push_back(make_pair(19, 20));
  vec[3].push_back(make_pair(23, 24));
  vec[4].push_back(make_pair(2, 4));
  vec[4].push_back(make_pair(6, 8));
  vec[4].push_back(make_pair(10, 12));
  vec[4].push_back(make_pair(23, 21));
  vec[5].push_back(make_pair(1, 2));
  vec[5].push_back(make_pair(18, 20));
  vec[5].push_back(make_pair(12, 11));
  vec[5].push_back(make_pair(15, 13));
  bool flag = false;
  int freq[25];
  for (i = 0; i < 6; i++) {
    vector<pair<int, int> > temp;
    for (j = 0; j < 4; j++) temp.push_back(vec[i][(j + 1) % 4]);
    for (j = 1; j <= 24; j++) freq[j] = arr[j];
    for (j = 0; j < 4; j++) {
      freq[vec[i][j].first] = arr[temp[j].first];
      freq[vec[i][j].second] = arr[temp[j].second];
    }
    flag = check(freq);
    if (flag) break;
  }
  if (flag) {
    cout << "YES";
    return 0;
  }
  for (i = 0; i < 6; i++) {
    vector<pair<int, int> > temp;
    for (j = 0; j < 4; j++) temp.push_back(vec[i][((j - 1) + 4) % 4]);
    for (j = 1; j <= 24; j++) freq[j] = arr[j];
    for (j = 0; j < 4; j++) {
      freq[vec[i][j].first] = arr[temp[j].first];
      freq[vec[i][j].second] = arr[temp[j].second];
    }
    flag = check(freq);
    if (flag) break;
  }
  if (flag)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
