R1 = [35.5, 37.5, 40.0, 43.0, 50.0, 55.0, 70.0]
R2 = [71.0, 77.0, 83.0, 89.0, 105.0, 116.0, 148.0]
B = %w[AAA AA A B C D E]
$<.each do |l|
  t1, t2 = l.split.map(&:to_f)
  r1 = R1.find_index {|t| t1 < t }
  r2 = R2.find_index {|t| t2 < t }
  puts r1 && r2 ? B[[r1, r2].max] : 'NA'
end