$<.gets.to_i.times do
  h, m = $<.gets.split(":").map(&:to_r)
  l = m * 6
  s = (h * 60 + m) / 2
  r = (l - s).abs
  r = 360 - r if r > 180
  st = if 0 <= r and r < 30
    "alert"
  elsif 90 <= r and r <= 180
    "safe"
  else
    "warning"
  end
  puts st
end
