#include <bits/stdc++.h>
using namespace std;
void prin(vector<int> vec) {
  cout << "    ";
  cout << vec[1] << " " << vec[2] << endl;
  cout << "    ";
  cout << vec[3] << " " << vec[4] << endl;
  cout << vec[13] << " " << vec[14] << " ";
  cout << vec[5] << " " << vec[6] << " ";
  cout << vec[17] << " " << vec[18] << " ";
  cout << vec[21] << " " << vec[22] << endl;
  cout << vec[15] << " " << vec[16] << " ";
  cout << vec[7] << " " << vec[8] << " ";
  cout << vec[19] << " " << vec[20] << " ";
  cout << vec[23] << " " << vec[24] << endl;
  cout << "    ";
  cout << vec[9] << " " << vec[10] << endl;
  cout << "    ";
  cout << vec[11] << " " << vec[12] << endl;
  cout << endl << endl;
}
int main() {
  vector<int> cube(1, 0);
  for (int i = 0; i < 24; i++) {
    int t;
    cin >> t;
    cube.push_back(t);
  }
  vector<int> _cube;
  int x, y;
  vector<int> ini;
  ini = cube;
  for (int w = 0; w < 4; w++) {
    _cube = cube;
    x = _cube[3], y = _cube[4];
    _cube[3] = _cube[17];
    _cube[4] = _cube[19];
    _cube[17] = _cube[10];
    _cube[19] = _cube[9];
    _cube[10] = _cube[16];
    _cube[9] = _cube[14];
    _cube[16] = x;
    _cube[14] = y;
    bool bad = false;
    for (int i = 1; i < 24; i += 4) {
      for (int j = 0; j < 4; j++) {
        if (_cube[i] != _cube[i + j]) {
          bad = true;
          break;
        }
      }
      if (bad == true) break;
    }
    if (bad == false) {
      cout << "YES";
      return 0;
    }
    x = _cube[3], y = _cube[4];
    _cube[3] = _cube[17];
    _cube[4] = _cube[19];
    _cube[17] = _cube[10];
    _cube[19] = _cube[9];
    _cube[10] = _cube[16];
    _cube[9] = _cube[14];
    _cube[16] = x;
    _cube[14] = y;
    x = _cube[3], y = _cube[4];
    _cube[3] = _cube[17];
    _cube[4] = _cube[19];
    _cube[17] = _cube[10];
    _cube[19] = _cube[9];
    _cube[10] = _cube[16];
    _cube[9] = _cube[14];
    _cube[16] = x;
    _cube[14] = y;
    bad = false;
    for (int i = 1; i < 24; i += 4) {
      for (int j = 0; j < 4; j++) {
        if (_cube[i] != _cube[i + j]) {
          bad = true;
          break;
        }
      }
      if (bad == true) break;
    }
    if (bad == false) {
      cout << "YES";
      return 0;
    }
    vector<int> tem(1, 0);
    tem.push_back(cube[24]);
    tem.push_back(cube[23]);
    tem.push_back(cube[22]);
    tem.push_back(cube[21]);
    tem.insert(tem.end(), cube.begin() + 1, cube.begin() + 5);
    tem.insert(tem.end(), cube.begin() + 5, cube.begin() + 9);
    tem.push_back(cube[15]);
    tem.push_back(cube[13]);
    tem.push_back(cube[16]);
    tem.push_back(cube[14]);
    tem.push_back(cube[18]);
    tem.push_back(cube[20]);
    tem.push_back(cube[17]);
    tem.push_back(cube[19]);
    tem.insert(tem.end(), cube.begin() + 9, cube.begin() + 13);
    cube = tem;
  }
  vector<int> tem;
  tem = cube;
  x = tem[1], y = tem[3];
  tem[1] = tem[5];
  tem[3] = tem[7];
  tem[5] = tem[9];
  tem[7] = tem[11];
  tem[9] = tem[24];
  tem[11] = tem[22];
  tem[24] = x;
  tem[22] = y;
  x = tem[13];
  tem[13] = tem[14];
  tem[14] = tem[16];
  tem[16] = tem[15];
  tem[15] = x;
  bool bad = false;
  for (int i = 1; i < 24; i += 4) {
    for (int j = 0; j < 4; j++) {
      if (tem[i] != tem[i + j]) {
        bad = true;
        break;
      }
    }
    if (bad == true) break;
  }
  if (bad == false) {
    cout << "YES";
    return 0;
  }
  cube = tem;
  x = tem[1], y = tem[3];
  tem[1] = tem[5];
  tem[3] = tem[7];
  tem[5] = tem[9];
  tem[7] = tem[11];
  tem[9] = tem[24];
  tem[11] = tem[22];
  tem[24] = x;
  tem[22] = y;
  x = tem[13];
  tem[13] = tem[14];
  tem[14] = tem[16];
  tem[16] = tem[15];
  tem[15] = x;
  x = tem[1], y = tem[3];
  tem[1] = tem[5];
  tem[3] = tem[7];
  tem[5] = tem[9];
  tem[7] = tem[11];
  tem[9] = tem[24];
  tem[11] = tem[22];
  tem[24] = x;
  tem[22] = y;
  x = tem[13];
  tem[13] = tem[14];
  tem[14] = tem[16];
  tem[16] = tem[15];
  tem[15] = x;
  bad = false;
  for (int i = 1; i < 24; i += 4) {
    for (int j = 0; j < 4; j++) {
      if (tem[i] != tem[i + j]) {
        bad = true;
        break;
      }
    }
    if (bad == true) break;
  }
  if (bad == false) {
    cout << "YES";
    return 0;
  }
  cube = ini;
  x = cube[2], y = cube[4];
  cube[2] = cube[6];
  cube[4] = cube[8];
  cube[6] = cube[10];
  cube[8] = cube[12];
  cube[10] = cube[23];
  cube[12] = cube[21];
  cube[23] = x;
  cube[21] = y;
  x = cube[18];
  cube[18] = cube[17];
  cube[17] = cube[19];
  cube[19] = cube[20];
  cube[20] = x;
  bad = false;
  for (int i = 1; i < 24; i += 4) {
    for (int j = 0; j < 4; j++) {
      if (cube[i] != cube[i + j]) {
        bad = true;
        break;
      }
    }
    if (bad == true) break;
  }
  if (bad == false) {
    cout << "YES";
    return 0;
  }
  x = cube[2], y = cube[4];
  cube[2] = cube[6];
  cube[4] = cube[8];
  cube[6] = cube[10];
  cube[8] = cube[12];
  cube[10] = cube[23];
  cube[12] = cube[21];
  cube[23] = x;
  cube[21] = y;
  x = cube[18];
  cube[18] = cube[17];
  cube[17] = cube[19];
  cube[19] = cube[20];
  cube[20] = x;
  x = cube[2], y = cube[4];
  cube[2] = cube[6];
  cube[4] = cube[8];
  cube[6] = cube[10];
  cube[8] = cube[12];
  cube[10] = cube[23];
  cube[12] = cube[21];
  cube[23] = x;
  cube[21] = y;
  x = cube[18];
  cube[18] = cube[17];
  cube[17] = cube[19];
  cube[19] = cube[20];
  cube[20] = x;
  bad = false;
  for (int i = 1; i < 24; i += 4) {
    for (int j = 0; j < 4; j++) {
      if (cube[i] != cube[i + j]) {
        bad = true;
        break;
      }
    }
    if (bad == true) break;
  }
  if (bad == false) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
