import scala.io.Source.stdin

object Main {

  def getFigure(a:Array[Array[Int]]):String = {
    def f(i:Int,j:Int) = if(i>=0 && j>=0 && i<8 && j<8) a(i)(j) else 0
    def loop(i:Int,j:Int):String = {
      (i,j) match {
        case (7,7) => "NG"
        case (i,j) =>
          if(a(i)(j) == 1) {
            (f(i,j+1),f(i,j+2),f(i+1,j),f(i+2,j),f(i+1,j+1),f(i+1,j-1)) match {
              case (1,0,1,0,1,0) => "A"
              case (0,0,1,1,0,0) => "B"
              case (1,1,0,0,0,0) => "C"
              case (0,0,1,0,0,1) => "D"
              case (1,0,0,0,1,0) => "E"
              case (0,0,1,0,1,0) => "F"
              case (1,0,1,0,0,1) => "G"
              case (_,_,_,_,_,_) => "NG"
            }
          } else { if(j==7) loop(i+1,0) else loop(i,j+1) }
      }
    }
    loop(0,0)
  }

  def main(args:Array[String]) = {
    stdin.getLines.filter(_!="").sliding(8,8).foreach { s =>
      println { getFigure({for(i <- s) yield i.toArray.map(_.asDigit)}.toArray) }
    }
  }
}