#include <cstdio>
#include <cctype>
#include <algorithm>
using namespace std;

char c[8][10];
const int x[24][6] = {
  {0, 1, 2, 4, 3, 5},
  {0, 2, 4, 3, 1, 5},
  {0, 4, 3, 1, 2, 5},
  {0, 3, 1, 2, 4, 5},
  {1, 0, 3, 5, 2, 4},
  {1, 3, 5, 2, 0, 4},
  {1, 5, 2, 0, 3, 4},
  {1, 2, 0, 3, 5, 4},
  {2, 0, 1, 5, 4, 3},
  {2, 1, 5, 4, 0, 3},
  {2, 5, 4, 0, 1, 3},
  {2, 4, 0, 1, 5, 3},
  {3, 0, 4, 5, 1, 2},
  {3, 4, 5, 1, 0, 2},
  {3, 5, 1, 0, 4, 2},
  {3, 1, 0, 4, 5, 2},
  {4, 0, 2, 5, 3, 1},
  {4, 2, 5, 3, 0, 1},
  {4, 5, 3, 0, 2, 1},
  {4, 3, 0, 2, 5, 1},
  {5, 1, 3, 4, 2, 0},
  {5, 3, 4, 2, 1, 0},
  {5, 4, 2, 1, 3, 0},
  {5, 2, 1, 3, 4, 0}
};
pair<int, int> a[8];
bool used[8];

bool fit(char p, char q) {
  return (isupper(p) && islower(q) && tolower(p) == q) 
    || (islower(p) && isupper(q) && toupper(p) == q);
}

bool dfs(int n) {
  char p, q;
  if (n == 8) return true;
  for (int i=0; i<8; i++) {
    if (used[i]) continue;
    for (int j=0; j<24; j++) {
      if (n & 1) {
        p = c[a[n-1].first][x[a[n-1].second][1]];
        q = c[i][x[j][3]];
        if (!fit(p,q)) continue;
      }
      if (n & 2) {
        p = c[a[n-2].first][x[a[n-2].second][2]];
        q = c[i][x[j][4]];
        if (!fit(p,q)) continue;
      }
      if (n & 4) {
        p = c[a[n-4].first][x[a[n-4].second][0]];
        q = c[i][x[j][5]];
        if (!fit(p,q)) continue;
      }
      used[i] = true;
      a[n].first = i;
      a[n].second = j;
      if (dfs(n+1)) return true;
      used[i] = false;
    }
  }
  return false;
}

int main() {
  while (1) {
    fgets(c[0], sizeof(c[0]), stdin);
    if (c[0][0] == '0') break;
    for (int i=1; i<8; i++) {
      fgets(c[i], sizeof(c[i]), stdin);
    }
    for (int i=0; i<8; i++) {
      used[i] = false;
    }
    if (dfs(0)) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}