#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <bitset>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

// dice<hoge> di(arr); ÈÇÆé¾·é
// ±ÌÆ«AarrÍ hoge di[6];Åé¾³êÄ¨èAid ÌlÌÉÊÌlªi[³êÄ¢éKvª éB
// á¦ÎAid[TOP] = 3 ÈçÎAdi[3] ÌlªTOPÉÝè³êéB
// TCRÆµÄµ¢©Ç¤©Ì»èÉ equivalent_to ðg¤B
enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
template <class T>
class dice {
public:
  dice(){}
  dice(T *v) {
    id[TOP] = 0; id[FRONT] = 1; id[RIGHT] = 2;
    id[LEFT] = 3; id[BACK] = 4; id[BOTTOM] = 5;
    REP(i,6)
      var[i] = v[i];
  }
  T& operator[] (FACE f) { return var[id[f]]; }
  const T& operator[] (FACE f) const { return var[id[f]]; }
  bool operator==(const dice<T>& b) const {
    const dice<T> &a = *this;
    return a[TOP] == b[TOP] && a[BOTTOM] == b[BOTTOM] &&
           a[FRONT] == b[FRONT] && a[BACK] == b[BACK] &&
           a[LEFT] == b[LEFT] && a[RIGHT] == b[RIGHT];
  }
  void roll_x() { roll(TOP, BACK, BOTTOM, FRONT); }
  void roll_y() { roll(TOP, LEFT, BOTTOM, RIGHT); }
  void roll_z() { roll(FRONT, RIGHT, BACK, LEFT); }
  vector<dice> all_rolls() {
    vector<dice> ret;
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        ret.push_back(*this);
    return ret;
  }
  bool equivalent_to(const dice& di) {
    for (int k = 0; k < 6; (k&1?roll_y():roll_x()),++k)
      for (int i = 0; i < 4; roll_z(), ++i)
        if (*this == di) return true;
    return false;
  }
private:
  void roll(FACE a, FACE b, FACE c, FACE d) {
    int tmp = id[a];
    id[a] = id[b]; id[b] = id[c];
    id[c] = id[d]; id[d] = tmp;
  }
  T var[6];
  int id[6];
};

typedef vector<dice<char> > vdc;
vdc di(8);

char hoge(char a) {
  return isupper(a) ? tolower(a) : toupper(a);
}


bool step7(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[3][BACK]) == (*it)[FRONT]
          && hoge(vd[5][BOTTOM]) == (*it)[TOP]
          && hoge(vd[6][RIGHT]) == (*it)[LEFT]) {
        return true;
      }
    }
  }
  return false;
}
bool step6(vdc vd, int S) {
  // cout << bitset<8>(S) << " " << vd[4][FRONT] << endl;
  // REP(i, vd.size()) {
  //   cout << i << ": ";
  //   cout << vd[i][TOP] << vd[i][FRONT] << vd[i][RIGHT];
  //   cout << vd[i][LEFT] << vd[i][BACK] << vd[i][BOTTOM];
  //   cout << endl;
  // }
  // cout << hoge(vd[2][BACK]) << " "  << hoge(vd[4][BOTTOM]) << endl;
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[2][BACK]) == (*it)[FRONT] && hoge(vd[4][BOTTOM]) == (*it)[TOP]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step7(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}
bool step5(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[1][BACK]) == (*it)[FRONT] && hoge(vd[4][RIGHT]) == (*it)[LEFT]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step6(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}

bool step4(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[0][BACK]) == (*it)[FRONT]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step5(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}

bool step3(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[1][BOTTOM]) == (*it)[TOP] && hoge(vd[2][RIGHT]) == (*it)[LEFT]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step4(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}

bool step2(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    if (S & (1<<i)) continue;
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[0][BOTTOM]) == (*it)[TOP]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step3(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}

bool step1(vdc vd, int S) {
  for (int i = 1; i<8; ++i) {
    vdc v = di[i].all_rolls();
    FOR(it, v) {
      if (hoge(vd[0][RIGHT]) == (*it)[LEFT]) {
        vdc tmp = vd;
        tmp.push_back(*it);
        if (step2(tmp, S|(1<<i))) return true;
      }
    }
  }
  return false;
}

int main() {
  string s;
  while(cin >> s, s!="0") {
    REP(k,8) {
      if (k) cin >> s;
      char a[6];
      REP(i,6) a[i] = s[i];
      di[k] = dice<char>(a);
    }
    vdc ve = di[0].all_rolls();
    bool f = 0;
    FOR(it, ve) {
      vdc tmp;
      tmp.push_back(*it);
      if (step1(tmp, 1)) {
        f = 1;
        break;
      }
    }
    if (f)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}

Measured memory_bytes: 928