#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	
	int n, h, m, diff;
	
	cin >> n;
	
	string str;
	
	for(int loop = 0; loop < n; loop++){
		cin >> str;
		h = (str[0] - '0') * 10 + (str[1] - '0');
		m = (str[3] - '0') * 10 + (str[4] - '0');
		diff = abs((h * 60 + m) - m * 12);
		if(diff > 360){
			diff = 720 - diff;
		}
		if(diff < 60){
			printf("alert\n");
		}else if(diff < 180){
			printf("warning\n");
		}else{
			printf("safe\n");
		}
	}
	
	return 0;
}