#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int a,b,n;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%d%c%d",&a,&c,&b);
	a*=30; b*=6;
	b=(720+b-a) % 360;
    cout << "b=" << b << endl;
	b= b >180 ? 360-b : b;
	if (b<=30) cout << "alert" << endl; else
		if (b>=90) cout << "safe" << endl; else cout << "warning" << endl;
	cout << "b=" << b << endl;
	}
return 0;
}