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

string func(int s, int l){
	int a = l * 6;
	int b = s * 30 + l / 2;
	if(30 <= abs(a - b)){
		if(90 <= abs(a -b))return "safe";
		return "warning";
	}else return "alert";
	cout << a  << " " << b;
	return "a";
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}