def check_cheese_max_size(a, b, c)
    return [a, b, c].max
end

def check_cheese_entry(entry, cheese)
    if entry * 2 > cheese
        return true
    else
        return false
    end
end

c_depth, c_width, c_height = gets.chomp.split(' ').map!(&:to_i)
entry_num = gets.to_i

cheese_maxsize = check_cheese_max_size(c_depth, c_width, c_height)

while
    input_lines = gets.chomp
    break if input_lines == "0 0 0"
    entry_radius = input_lines.to_i
    case check_cheese_entry(entry_radius, cheese_maxsize)
    when true
        puts "OK"
    when false
        puts "NA"
    end
end