import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int n = readln().chomp().to!int;
    for(int i=0;i<n;i++){
	auto s = readln().chomp().split(':');
	int h = s[0][0] == '0' ? to!int(s[0][1]-'0') : to!int(s[0]);
	int w = s[1][0] == '0' ? to!int(s[1][1]-'0') : to!int(s[1]);
	real angleh,anglew;
	h %= 12;
	angleh = to!real(h) / 12.0 * 360.0 + to!real(w) / 60.0 * 30.0;
	anglew = to!real(w) / 60.0 * 360.0;
	real angle = min(abs(angleh-anglew),360-abs(angleh-anglew));
	if(angle < 30.0) writeln("alert");
	else if(90 <= angle && angle <= 180) writeln("safe");
	else writeln("warning");
    }

}