#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,h,m,tan,tyo,sa,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)	{
		scanf("%d:%d",&h,&m);
		tan=h*300+m*5;
		tyo=m*60;
		sa=tan-tyo;
		if(sa<0)	sa=-sa;
		if(sa>1800)	sa=3600-sa;
		if(sa<300)	printf("alert\n");
		else if(sa>=900)	printf("safe\n");
		else printf("warning\n");
	}
	return 0;
}
