#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;


int main(){

	int n;
	scanf("%d",&n);

	double hour,minute,degree1,degree2;

	char buf[6];

	for(int i=0; i < n; i++){
		scanf("%s",buf);

		hour = 10*(buf[0]-'0')+(buf[1]-'0');
		minute = 10*(buf[3]-'0')+(buf[4]-'0');

		degree1 = 360*(minute/60);
		degree2 = (60*hour+minute)/2;

		if(fabs(degree1-degree2) < 30.0){
			printf("alert\n");
		}else if(fabs(degree1-degree2) < 90.0){
			printf("warnin\n");
		}else{
			printf("safe\n");
		}
	}

    return 0;
}