#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EPS (1e-8)

int getNum(string str, int pos) {
	return (str[pos] - '0') * 10 + str[pos + 1] - '0';
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = abs(angle1 - angle2);
		cout << div << endl;
		
		if (div >= -EPS && div < 30.0 - EPS)
			puts("alert");
		else if (div >= 90.0 - EPS && div <= 180.0 + EPS)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}