import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
    val p = (x: Int) => math.pow(x, 2)
    val sc = new Scanner(System.in)

    var xyz = List(sc.nextInt, sc.nextInt, sc.nextInt).sorted

    while (xyz != List(0, 0, 0)) {
      val enterable = math.sqrt(p(xyz.head) + p(xyz(1))) / 2

      (0 until sc.nextInt).map(_ => if (sc.nextInt > enterable) "OK" else "NA").foreach(println)

      xyz = List(sc.nextInt, sc.nextInt, sc.nextInt).sorted
    }

    sc.close()
  }
}