Up, Frnt, Rt, Lft, Bk, Dwn = *(0...6)

def check(d)
  4.times.map{
    d = [d[Rt], d[Frnt], d[Dwn], d[Up], d[Bk], d[Lft]]
    4.times.map {
      d = [d[Up], d[Rt], d[Bk], d[Frnt], d[Lft], d[Dwn]]
      4.times.map {
        d = [d[Frnt], d[Dwn], d[Rt], d[Lft], d[Up], d[Bk]]
      }
    }
  }.flatten(2).uniq
end

@dir = check((0...6).to_a)

Conn = [[],
        [[0, Lft, Rt]],
        [[0, Bk, Frnt]],
        [[1, Bk, Frnt], [2, Lft, Rt]],
        [[0, Up, Dwn]],
        [[1, Up, Dwn], [4, Lft, Rt]],
        [[2, Up, Dwn], [4, Bk, Frnt]],
        [[3, Up, Dwn], [5, Bk, Frnt], [6, Lft, Rt]]
]

def dfs(pos)
  return true if pos == 8
  (pos...8).each do |r|
    @dir.each do |d|
      ok = true
      Conn[pos].each do |conn_to, me, opposite|
        a = @dice[r][d[me]]
        b = @dice[@res[conn_to]][@res_d[conn_to][opposite]]
        unless a.ord - b.ord == 32
          ok = false
          break
        end
      end
      if ok
        return true if dfs(pos+1)
      end
    end
  end
  false
end

def solve
  @dir.each do |d|
    return true if dfs(0)
  end
  false
end

while (l = gets.chomp) != '0'
  @dice = [l.split(''), *7.times.map{gets.chomp.split('')}]
  @res_d = [[d], *7.times.map{ [] } ]
  @res = [[0], *7.times.map{ [] } ]
  puts solve ? 'YES' : 'NO'
end