Problem:


Carry a Cheese

Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size A &times; B &times; C. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own radius R. Could you help Jerry to find suitable holes to be survive?

Your task is to create a program which estimates whether Jerry can trail the cheese via each hole.
The program should print "OK" if Jerry can trail the cheese via the corresponding hole (without touching it). Otherwise the program should print "NA".

You may assume that the number of holes is less than 10000.

Input

The input is a sequence of datasets. The end of input is indicated by a line containing three zeros. Each dataset is formatted as follows:

A B C
n
R1
R2

 .
 .
Rn

n indicates the number of holes (entrances) and Ri indicates the radius of i-th hole.

Output

For each datasets, the output should have n lines. Each line points the result of estimation of the corresponding hole. 

Sample Input

10 6 8
5
4
8
6
2
5
0 0 0

Output for the Sample Input

NA
OK
OK
NA
NA



Sample input:
10 6 8
5
4
8
6
2
5
0 0 0


Sample output:
NA
OK
OK
NA
NA

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

def printA(A):
    N = len(A)
    for i, n in enumerate(A):
        print(n, end='')
        if i != N-1:
            print(' ', end='')
    print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            N.append(input())
            #N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

while True:
    D, W, H = [int(x) for x in input().split()]
    if D==0 and W==0 and H==0:
        break
    N = int(input())

    for i in range(N):
        r = int(input())
        r1 = (D*D+W*W)**(1/2)/2
        r2 = (W*W+H*H)**(1/2)/2
        r3 = (H*H+D*D)**(1/2)/2
        rm = min([r1,r2,r3])
        if r > rm:
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
while True:
    a=sorted(list(map(int,input().split())))
    if sum(a)==0:
        break
    s=min(a[0]**2+a[1]**2,a[1]**2+a[2]**2,a[0]**2+a[2]**2)
    n=int(input())
    for i in range(n):
        r=int(input())
        print("OK" if (r*2)**2>s else "NA")

Submission status: Accepted

Solution code:
import math

if __name__ == '__main__':
    
    while True:
        d,w,h = map(int,input().split())
        if d == 0 and w == 0 and h == 0:
            break
    
        a1 = math.sqrt(d*d + h*h)
        a2 = math.sqrt(d*d + w*w)
        a3 = math.sqrt(h*h + w*w)
        n = int(input())

        for _ in range(n):
            c = int(input())
            if c*2 <= a1 and c*2 <= a2 and c*2 <= a3:
                print("NA")
            else:
                print("OK")

Submission status: Accepted

Solution code:
while 1:
    cheese=list(map(int,input().split()))
    if cheese[0]==0:break
    n=int(input())
    cheese=sorted(cheese)
    for i in range(n):
        radius = int(input())
        if radius*2>(cheese[0]**2+cheese[1]**2)**0.5:print("OK")
        else:print("NA")

Submission status: Accepted

Solution code:
while 1:
    try:
        dwh=list(map(int,input().split()))
        if dwh[0]==dwh[1]==dwh[2]==0:break
        dwh.sort()
        std=(dwh[0]**2+dwh[1]**2)**0.5/2
        n=int(input())
        for i in range(n):
            r=int(input())
            if std<r:print("OK")
            else:print("NA")
    except:break

Submission status: Accepted

Solution code:
import math

while 1:
    d, w, h = map(int, input().split())
    if d == 0:
        break

    datas = []
    n = int(input())
    for _ in range(n):
        r = int(input())
        datas.append(r)

    cheese = [d, w, h]
    cheese.sort()
    a = cheese[0]
    b = cheese[1]
    r = math.sqrt(a**2 + b**2) / 2

    for data in datas:
        if r >= data:
            print("NA")
        else:
            print("OK")

Submission status: Accepted

Solution code:
while True:
    d, w, h = map(int, input().split())
    if d == 0:
        break
    d = min(d**2 + w**2, w**2 + h**2, h**2 + d**2)
    n = int(input())
    for i in range(n):
        d_i = (int(input())*2)**2
        if d_i > d:
            print("OK")
        else:
            print("NA")

Submission status: Accepted

Solution code:
while True:
    d, w, h = sorted(map(int, input().split()))
    if d == w == h == 0:
        break
    dw = (d**2 + w**2)
    n = int(input())
    for i in range(n):
        y = int(input())
        if (2*y)**2 > dw:
            print("OK")
        else:
            print("NA")

Submission status: Accepted

Solution code:
while True:
    ch = list(map(int,input().split()))
    if (0 in ch):
        break
    ch.sort()
    n = int(input())
    a = ch[0]
    b = ch[1]
    d = a**2 + b**2
    for i in range(n):
        r = int(input())
        R = 2*r
        if (R**2 > d):
            print('OK')
        else:
            print('NA')

Submission status: Accepted

Solution code:
t = []
temp = 0
while True:
        d,w,h = [int(s) for s in input().split(' ')]
        if d < w:
            temp = d
        else:
            temp = w
        if d == 0 and w == 0 and h == 0:
            break
        else:
            n = int(input())
            for i in range(n):
                t.append(i)
                t[i] = int(input())
                if (temp/2) ** 2 + (h/2) ** 2 < t[i] ** 2:
                    print("OK")
                else:
                    print("NA")

Submission status: Accepted

Solution code:
while(True):
    d,w,h = map(int, input().split())
    if d == 0 and w == 0 and h == 0:
        break
    l = min(d*d+w*w,w*w+h*h,h*h+d*d)
    n = int(input())
    for i in range(n):
        r = int(input())
        if 4*r*r > l:
            print("OK")
        else:
            print("NA")

Submission status: Runtime Error

Solution code:
def hantei(A,B,C,R=0):
    h,t = sorted([A,B,C])[:2]
    if h**2 + t**2 < 4 * R**2:
        print 'OK'
    else:
        print 'NA'

while True:
    try:
        A,B,C = map(int,raw_input().split())
    except EOFError:
        break

    for k in range(int(raw_input())):
        hantei(A,B,C,int(raw_input()))
    
    a,b,c = map(int,raw_input().split())
    if (a,b,c) == (0,0,0):
        break

Submission status: Runtime Error

Solution code:
def min_diag(A,B,C):
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(int,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = int(input())

  # process
  min_diag = min_diag(A,B,C)

  # judge & output
  for r in R:
    if min_diag < 2*r:
      print("OK")
    else:
      print("NA")

Submission status: Runtime Error

Solution code:
def min_diag(A,B,C):
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(float,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = float(input())

  # process
  min_diag = min_diag(A,B,C)

  # judge & output
  for r in R:
    if min_diag < 2*r:
      print("OK")
    else:
      print("NA")

Submission status: Runtime Error

Solution code:
def min_diag(A,B,C):
  segments=[A,B,C]
  segments.sort()
  return (segments[0]**2+segments[1]**2)**(1/2)

while True:
  # input one dataset
  A,B,C = tuple(map(float,input().split()))
  if (A,B,C) == (0,0,0):
    break
  n = int(input())
  R = [None]*n
  for i in range(n):
    R[i] = float(input())
  # process
  min_diag = min_diag(A,B,C)
  # judge & output
  for r in R:
    if min_diag < 2*r:
      print("OK")
    else:
      print("NA")

Submission status: Runtime Error

Solution code:
while 1:
    d, w, h = map(int, raw_input().split())
    dmin = min(d**2 + w**2, w**2+h**2, h**2+d**2)
    if dmin == 0:
        break
    n = input()
    for i in range(n):
        r = input()
        if dmin < 2*r**2:
            print 'OK'
        else:
            print 'NA'

Submission status: Runtime Error

Solution code:
import sys
for a in sys.stdin:
 if'0'==a:break
 s=list(map(int,input().split()))
 c=0
 while 1:
  t=s;s=[t.count(e)for e in t]
  if t==s:break
  c+=1
 print(c);print(*s)

Submission status: Runtime Error

Solution code:
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0:  break
	min = min(d*d+w*w, d*d+h*h, w*w+h*h)
	for _ in range(int(input())):
		r = int(input())
		print('OK' if min < (2*r)**2 else 'NA')

Submission status: Runtime Error

Solution code:
# AOJ 0107 Carry a Cheese
# Python3 2018.6.17 bal4u

while True:
	d, w, h = list(map(int, input().split()))
	if d == 0 and w == 0 and h == 0: break
	min = min(d*d+w*w, d*d+h*h, w*w+h*h)

	n = int(input())
	for i in range(n):
		r = int(input())
		print('OK' if (2*r)**2 > min else 'NA')

Submission status: Runtime Error

Solution code:
import math

i, size = 0, 0
rs = []
while True:
    line = raw_input()
    if line == '0 0 0':
        for r in rs:
            if size <= r:
                print 'OK'
            else:
                print 'NA'
        break
    else:
        i += 1
    if i == 1:
        t = [int(n) for n in line.split()]
        t.sort()
        size = int(math.ceil(math.sqrt(t[0] * t[0] + t[1] * t[1])))
    if i > 2:
        rs.append(int(line))

Submission status: Runtime Error

Solution code:
from math import sqrt
cheeze = map(float,raw_input().split())
cheeze.sort()
supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2)
while True:
	k = raw_input()
	if k == "0 0 0": break
	else:
		k = int(k)
		if k < supk: print "OK"
		else: print "NA"

Submission status: Runtime Error

Solution code:
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheese[0]/2)**2 + (cheese[1]/2)**2)
nyu = map(int,nyu[2:])
try:
	for k in nyu:
		if k < supk: print "OK"
		else: print "NA"
except:
	pass

Submission status: Runtime Error

Solution code:
import sys
from math import sqrt

nyu = sys.stdin.read()
nyu = nyu.split("\n")
cheese = map(float,nyu[0].split())
cheese.sort()
supk = sqrt((cheese[0]/2)**2 + (cheese[1]/2)**2)
nyu = map(int,nyu[2:-1])
try:
	for k in nyu:
		if k < supk: print "OK"
		else: print "NA"
except:
	pass