#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,h,w,x;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		h=10*(s[0]-'0')+s[1]-'0';
		w=10*(s[3]-'0')+s[4]-'0';
		h*=30,w*=6;
		if(h>w)x=h-w;
		else x=w-h;
		if(x>180)x=360-x;
		if(x>=90)cout<<"safe"<<endl;
		if(x<30)cout<<"alert"<<endl;
		if(x>=30&&x<90)cout<<"warning"<<endl;
	}
	return 0;
}