#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > c(6, vector<int>(4, 0));   bool full[6];   bool polu[6];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(nullptr);     for (int i = 0; i < 6; ++i) {       bool was[7] = {};       for (int j = 0; j < 4; ++j) {         cin >> c[i][j];         was[c[i][j]] = 1;       }       int cnt = 0;       for (int j = 1; j <= 6; ++j) cnt += was[j];       if (cnt == 1) full[i] = 1;       if (cnt == 2) polu[i] = 1;     }     int cnt1 = 0, cnt2 = 0;     for (int i = 0; i < 6; ++i) cnt1 += full[i], cnt2 += polu[i];     if (!(cnt1 == 2 && cnt2 == 4)) {       cout <<  NO ;       return 0;     }     if (full[0] && full[2]) {       int path[5] = {3, 1, 4, 5, 3};       bool ok = true;       for (int i = 0; i < 4; ++i) {         if (!(c[path[i]][0] == c[path[i]][1] &&               c[path[i + 1]][2] == c[path[i + 1]][3] &&               c[path[i]][0] == c[path[i + 1]][2])) {           ok = false;           break;         }       }       for (int i = 4; i > 0; --i) {         if (!(c[path[i]][2] == c[path[i]][3] &&               c[path[i - 1]][0] == c[path[i - 1]][1] &&               c[path[i]][2] == c[path[i - 1]][0])) {           ok = false;           break;         }       }       if (ok) {         cout <<  YES ;         return 0;       }       ok = true;       for (int i = 0; i < 4; ++i) {         if (!(c[path[i]][2] == c[path[i]][3] &&               c[path[i + 1]][0] == c[path[i + 1]][1] &&               c[path[i]][2] == c[path[i + 1]][0])) {           ok = false;           break;         }       }       for (int i = 4; i > 0; --i) {         if (!(c[path[i]][0] == c[path[i]][1] &&               c[path[i - 1]][2] == c[path[i - 1]][3] &&               c[path[i]][0] == c[path[i - 1]][2])) {           ok = false;           break;         }       }       if (ok) {         cout <<  YES ;         return 0;       }       cout <<  NO ;     } else if (full[3] && full[4]) {       int path[5] = {0, 1, 2, 5, 0};       swap(c[5][0], c[5][1]);       swap(c[5][2], c[5][3]);       bool ok = true;       for (int i = 0; i < 4; ++i) {         if (!(c[path[i]][1] == c[path[i]][3] &&               c[path[i + 1]][0] == c[path[i + 1]][2] &&               c[path[i]][1] == c[path[i + 1]][0])) {           ok = false;           break;         }       }       for (int i = 4; i > 0; --i) {         if (!(c[path[i]][0] == c[path[i]][2] &&               c[path[i - 1]][1] == c[path[i - 1]][3] &&               c[path[i]][0] == c[path[i - 1]][1])) {           ok = false;           break;         }       }       if (ok) {         cout <<  YES ;         return 0;       }       ok = true;       for (int i = 0; i < 4; ++i) {         if (!(c[path[i]][0] == c[path[i]][2] &&               c[path[i + 1]][1] == c[path[i + 1]][3] &&               c[path[i]][0] == c[path[i + 1]][1])) {           ok = false;           break;         }       }       for (int i = 4; i > 0; --i) {         if (!(c[path[i]][1] == c[path[i]][3] &&               c[path[i - 1]][0] == c[path[i - 1]][2] &&               c[path[i]][1] == c[path[i - 1]][0])) {           ok = false;           break;         }       }       if (ok) {         cout <<  YES ;         return 0;       }       cout <<  NO ;     } else if (full[1] && full[5]) {       int path[5] = {0, 4, 2, 3, 0};       swap(c[4][1], c[4][2]);       swap(c[2][0], c[2][3]);       swap(c[2][1], c[2][2]);       swap(c[3][0], c[3][3]);       bool ok = true;       for (int i = 0; i < 4; ++i) {         if (i % 2 == 0) {           if (!(c[path[i]][0] == c[path[i]][1] &&                 c[path[i + 1]][0] == c[path[i + 1]][1] &&                 c[path[i]][0] == c[path[i + 1]][0])) {             ok = false;             break;           }         } else {           if (!(c[path[i]][2] == c[path[i]][3] &&                 c[path[i + 1]][2] == c[path[i + 1]][3] &&                 c[path[i]][2] == c[path[i + 1]][2])) {             ok = false;             break;           }         }       }       for (int i = 4; i > 0; --i) {         if (i % 2 == 0) {           if (!(c[path[i]][2] == c[path[i]][3] &&                 c[path[i - 1]][2] == c[path[i - 1]][3] &&                 c[path[i]][2] == c[path[i - 1]][2])) {             ok = false;             break;           }         } else {           if (!(c[path[i]][0] == c[path[i]][1] &&                 c[path[i - 1]][0] == c[path[i - 1]][1] &&                 c[path[i]][0] == c[path[i - 1]][0])) {             ok = false;             break;           }         }       }       if (ok) {         cout <<  YES ;         return 0;       }       ok = true;       for (int i = 0; i < 4; ++i) {         if (i % 2 == 1) {           if (!(c[path[i]][0] == c[path[i]][1] &&                 c[path[i + 1]][0] == c[path[i + 1]][1] &&                 c[path[i]][0] == c[path[i + 1]][0])) {             ok = false;             break;           }         } else {           if (!(c[path[i]][2] == c[path[i]][3] &&                 c[path[i + 1]][2] == c[path[i + 1]][3] &&                 c[path[i]][2] == c[path[i + 1]][2])) {             ok = false;             break;           }         }       }       for (int i = 4; i > 0; --i) {         if (i % 2 == 1) {           if (!(c[path[i]][2] == c[path[i]][3] &&                 c[path[i - 1]][2] == c[path[i - 1]][3] &&                 c[path[i]][2] == c[path[i - 1]][2])) {             ok = false;             break;           }         } else {           if (!(c[path[i]][0] == c[path[i]][1] &&                 c[path[i - 1]][0] == c[path[i - 1]][1] &&                 c[path[i]][0] == c[path[i - 1]][0])) {             ok = false;             break;           }         }       }       if (ok) {         cout <<  YES ;         return 0;       }       cout <<  NO ;     } else       cout <<  NO ;     return 0;   }