#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <algorithm> 
#include <cmath> 
#include <string> 
#include <vector> 
#include <list> 
#include <queue> 
#include <stack> 
#include <set> 
#include <map> 
#include <bitset> 
#include <numeric> 
#include <climits> 
#include <cfloat> 
using namespace std; 

class Dice
{
public:
    vector<char> pip; // ì¼kãºÌÚ
    Dice(){
        pip.assign(6, -1);
    }
    void roll(int d){ // ì¼kE¶Éñ]
        int dir[][4] = {{4,2,5,0},{4,3,5,1},{4,0,5,2},{4,1,5,3},{0,3,2,1},{0,1,2,3}};
        char tmp = pip[dir[d][0]];
        for(int i=0; i<3; ++i)
            pip[dir[d][i]] = pip[dir[d][i+1]];
        pip[dir[d][3]] = tmp;
    }
};

vector<Dice> dice(8);
vector<vector<vector<Dice> > > cube(2, vector<vector<Dice> >(2, vector<Dice>(2)));

bool solve(int curr, bitset<8> used)
{
    if(curr == 8)
        return true;
    int x = curr % 2;
    int y = curr / 2 % 2;
    int z = curr / 4 % 2;

    for(int i=0; i<8; ++i){
        if(used[i])
            continue;
        used[i] = true;
        for(int j=0; j<6; ++j){
            if(j < 4)
                dice[i].roll(0);
            else{
                dice[i].roll(1);
                if(j == 5)
                    dice[i].roll(1);
            }
            for(int k=0; k<4; ++k){
                dice[i].roll(4);
                if(x == 1 && abs(cube[0][y][z].pip[0] - dice[i].pip[2]) != abs('A' - 'a'))
                    continue;
                if(y == 1 && abs(cube[x][0][z].pip[4] - dice[i].pip[5]) != abs('A' - 'a'))
                    continue;
                if(z == 1 && abs(cube[x][y][0].pip[3] - dice[i].pip[1]) != abs('A' - 'a'))
                    continue;
                cube[x][y][z] = dice[i];
                if(solve(curr + 1, used))
                    return true;
            }
        }
        used[i] = false;
    }

    return false;
}

int main()
{
    for(;;){
        for(int i=0; i<8; ++i){
            string s;
            cin >> s;
            if(s == "0")
                return 0;

            dice[i].pip[4] = s[0];
            dice[i].pip[0] = s[1];
            dice[i].pip[1] = s[2];
            dice[i].pip[3] = s[3];
            dice[i].pip[2] = s[4];
            dice[i].pip[5] = s[5];
        }

        if(solve(0, 0))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}