#include<iostream>
#include<vector>
#include<string>
using namespace std;

int main() {
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		double s=0;
		string p;
		cin >> p;		
		s = ((p[0] - '0') * 10 + (p[1] - '0')) * 30 - ((p[3] - '0') * 10 + (p[4] - '0'))*5.5;
		if (s < 0)s = s - s * 2;
		if (s > 360 - s)s = 360 - s;
		cout << s << endl;
			if (s < 30)cout << "alert" << endl;
			else if (s < 90)cout << "warning" << endl;
			else cout << "safe" << endl;
	}
}