#include <bits/stdc++.h>
using namespace std;

// If this structure is used for two-dimensional surface,
// it assumes that the face id[0] faces the positive direction of the Y axis,
// the face id[1] faces the positive direction of the X axis
// and id[2] is top of the dice.
struct Dice {
  int id[6], cnt;
  const static int f[3][3];

  Dice() { init(); }

  void init() {
    for(int i = 0; i < 6; ++i) {
      id[i] = i;
    }
    cnt = 0;
  }

  // type (0:spin, 1:rollX, 2:rollY)
  // dir 1( ccw     neg      pos   )
  //    -1( cw      pos      neg   )
  void rotate(int type, int dir = 1) {
    const int *v = f[type];
    int a,b,c,t; a=v[0]; b=v[1]; c=v[2]; t=id[type];
    if(dir < 0) swap(a,c);
    id[type]=id[a]; id[a]=id[b]; id[b]=id[c]; id[c]=t;
  }

  bool next() {
    ++cnt;
    if(cnt == 24) {
      rotate(0,-1);
      rotate(1,-1);
      cnt = 0;
      return false;
    }
    if(cnt == 4*3) {
      rotate(2,-1);
      rotate(0,-1);
    } else if(cnt%4 == 0) {
      rotate(2);
    } else {
      rotate(0);
    }
    return true;
  }

  void roll(int dir) {
    //const static int dx[] = {1,0,-1,0};
    //const static int dy[] = {0,1,0,-1};
    switch(dir) {
      case 0: rotate(1,-1); break;
      case 1: rotate(2, 1); break;
      case 2: rotate(1, 1); break;
      case 3: rotate(2,-1); break;
    }
  }

  bool operator < (const Dice &d) const {
    for(int i = 0; i < 3; ++i)
      if(id[i] != d.id[i]) return id[i] < d.id[i];
    return false;
  }

  void show() {
    cout << id[4] << " / \\ " << id[5] << endl;
    cout << " /   \\" << endl;
    cout << "|\\ " << id[2] << " /|" << endl;
    cout << "|" << id[0] << "\\ /" << id[1] << "|" << endl;
    cout << " \\ | /" << endl;
    cout << "  \\|/" << endl;
    cout << "   " << id[3] << endl;
  }
};
const int Dice::f[3][3] = {{4,5,1},{3,4,2},{5,3,0}};


vector<string> F;
vector<int> used;
string S[2][2][2];
Dice G[2][2][2];

bool equals(char a, char b) {
  return ((bool)isupper(a) ^ (bool)isupper(b)) && (toupper(a) == toupper(b));
}

bool rec(int x, int y, int z) {
  static int dx[6] = {1,0,0,-1,0,0};
  static int dy[6] = {0,1,0,0,-1,0};
  static int dz[6] = {0,0,1,0,0,-1};
  static int p[6] = {1,0,2,4,5,3};
  static int q[6] = {4,5,3,1,0,2};
  if(x == 2) {
    x = 0;
    if(++y == 2) {
      y = 0;
      if(++z == 2) {
        return true;
      }
    }
  }
  //cout << x << ", " << y << ", " << z << endl;
  for(int i = 0; i < 8; ++i) {
    if(used[i]) continue;
    string &s = S[x][y][z];
    s = F[i];
    Dice &d = G[x][y][z];
    d = Dice();
    used[i] = true;
    do {
      try {
        for(int k = 0; k < 6; ++k) {
          int nx = x + dx[k];
          int ny = y + dy[k];
          int nz = z + dz[k];
          if(nx < 0 || nx >= 2) continue;
          if(ny < 0 || ny >= 2) continue;
          if(nz < 0 || nz >= 2) continue;
          const string &t = S[nx][ny][nz];
          if(t == "") continue;
          const Dice &e = G[nx][ny][nz];
          if(!equals(s[d.id[p[k]]], t[e.id[q[k]]])) throw 0;
        }
        if(rec(x+1,y,z)) return true;
      } catch(...) {}
    } while(d.next());
    used[i] = false;
    s = "";
  }
  return false;
}

int main() {
  while(1) {
    F.clear();
    for(int i = 0; i < 8; ++i) {
      string s;
      cin >> s;
      if(s == "0") return 0;
      string t(6,' ');
      t[2] = s[0];
      t[0] = s[1];
      t[1] = s[2];
      t[4] = s[3];
      t[5] = s[4];
      t[3] = s[5];
      F.push_back(t);
    }
    used = vector<int>(8,0);
    fill(S[0][0], S[2][0], "");
    if(rec(0,0,0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}