#include <bits/stdc++.h>
using namespace std;
int main() {
  int color[25];
  for (int i = 1; i <= 24; i++) {
    cin >> color[i];
  }
  set<int> st1, st2;
  for (int i = 13; i <= 16; i++) {
    st1.insert(color[i]);
  }
  for (int i = 17; i <= 20; i++) {
    st2.insert(color[i]);
  }
  if (st1.size() == 1 && st2.size() == 1) {
    if (color[1] == color[3] && color[5] == color[7] && color[9] == color[11] &&
        color[22] == color[24] && color[2] == color[4] &&
        color[6] == color[8] && color[10] == color[12] &&
        color[21] == color[23]) {
      if (color[1] == color[6]) {
        if (color[5] == color[10] && color[9] == color[21] &&
            color[2] == color[22]) {
          cout << "YES\n";
          return 0;
        }
      } else if (color[1] == color[21]) {
        if (color[2] == color[5] && color[9] == color[6] &&
            color[22] == color[10]) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  st1.clear();
  st2.clear();
  for (int i = 5; i <= 8; i++) {
    st1.insert(color[i]);
  }
  for (int i = 21; i <= 24; i++) {
    st2.insert(color[i]);
  }
  if (st1.size() == 1 && st2.size() == 1) {
    if (color[1] == color[2] && color[18] == color[20] &&
        color[11] == color[12] && color[13] == color[15] &&
        color[3] == color[4] && color[17] == color[19] &&
        color[9] == color[10] && color[14] == color[16]) {
      if (color[3] == color[18]) {
        if (color[17] == color[11] && color[9] == color[13] &&
            color[14] == color[1]) {
          cout << "YES\n";
          return 0;
        }
      } else if (color[3] == color[13]) {
        if (color[14] == color[11] && color[9] == color[18] &&
            color[17] == color[1]) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  st1.clear();
  st2.clear();
  for (int i = 1; i <= 4; i++) {
    st1.insert(color[i]);
  }
  for (int i = 9; i <= 12; i++) {
    st2.insert(color[i]);
  }
  if (st1.size() == 1 && st2.size() == 1) {
    if (color[5] == color[6] && color[17] == color[18] &&
        color[21] == color[22] && color[13] == color[14] &&
        color[7] == color[8] && color[19] == color[20] &&
        color[23] == color[24] && color[15] == color[16]) {
      if (color[5] == color[19]) {
        if (color[17] == color[23] && color[21] == color[15] &&
            color[13] == color[7]) {
          cout << "YES\n";
          return 0;
        }
      } else if (color[5] == color[15]) {
        if (color[13] == color[23] && color[21] == color[19] &&
            color[17] == color[7]) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  cout << "NO\n";
}
