#include <iostream>
#include <sstream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	char time[6];
	for(int i=0;i<n;i++){
		double a=0,b=0;
		cin >> time;
		for(int k=0;k<=9;k++){
			if(time[0]-'0' == k)
				a+= k*10;
			if(time[1]-'0' == k)
				a+= k;
			if(time[3]-'0' == k)
				b+= k*10;
			if(time[4]-'0' == k)
				b+= k;
		}
		double ans = max(a*30+b/2,b*6)-min(a*30+b/2,b*6);
		if((ans >= 0 && ans < 30) || (360 >= ans && ans > 330))
			cout << "alert" << endl;
		else if((ans >= 90 && ans <= 180) || (270 >= ans && ans >= 180))
			cout << "safe" << endl;
		else
			cout << "warning" << endl;
	}
	return 0;
}