#include <bits/stdc++.h>
using namespace std;
bool valid_V(vector<int> V) {
  for (int i = 0; i < V.size(); i += 4) {
    if (!(V[i] == V[i + 1] && V[i + 1] == V[i + 2] && V[i + 2] == V[i + 3]))
      return false;
  }
  return true;
}
bool tab1(vector<int> V) {
  int arr[] = {0, 2, 4, 6, 8, 10, 23, 21};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab2(vector<int> V) {
  int arr[] = {1, 3, 5, 7, 9, 11, 22, 20};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab3(vector<int> V) {
  int arr[] = {2, 0, 21, 23, 10, 8, 6, 4};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab4(vector<int> V) {
  int arr[] = {3, 1, 20, 22, 11, 9, 7, 5};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab5(vector<int> V) {
  int arr[] = {1, 0, 12, 14, 10, 11, 19, 17};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab6(vector<int> V) {
  int arr[] = {0, 1, 17, 19, 11, 10, 14, 12};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab7(vector<int> V) {
  int arr[] = {2, 3, 16, 18, 9, 8, 15, 13};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab8(vector<int> V) {
  int arr[] = {3, 2, 13, 15, 8, 9, 18, 16};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab9(vector<int> V) {
  int arr[] = {20, 21, 12, 13, 4, 5, 16, 17};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
bool tab10(vector<int> V) {
  int arr[] = {21, 20, 17, 16, 5, 4, 13, 12};
  int X = V[arr[0]];
  int Y = V[arr[1]];
  for (int i = 0; i <= 5; ++i) {
    V[arr[i]] = V[arr[i + 2]];
  }
  V[arr[6]] = X;
  V[arr[7]] = Y;
  return valid_V(V);
}
int main() {
  vector<int> V;
  for (int i = 0; i < 24; ++i) {
    int x;
    cin >> x;
    V.push_back(x);
  }
  bool bol = false;
  bol |= tab1(V);
  bol |= tab2(V);
  bol |= tab3(V);
  bol |= tab4(V);
  bol |= tab5(V);
  bol |= tab6(V);
  bol |= tab7(V);
  bol |= tab8(V);
  bol |= tab9(V);
  bol |= tab10(V);
  if (bol)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
