n = gets.to_i
n.times{
    h, m = gets.chomp.split(':').map(&:to_i)
    longhand = m * 6
    shorthand = h * 30 + 0.5 * m
    min, max = [shorthand, longhand].minmax
    kakudo = [max - min, 360 - max + min].min
    result = "safe"
    if kakudo < 30
        result = "alert"
    elsif kakudo < 90
        result = "warning"
    end
    puts result
}
