#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	cin>>n;
	double h,m;
	rep(i,0,n){
		scanf("%lf:%lf",&h,&m);
		if(h>=12) h-=12;
		h=30*h+0.5*m;
		m=6*m;
		double ans=abs(h-m);
		o(ans);
		if(ans>180) ans=360-ans;
		if(ans<30) o("alert");
		else if(ans>=90) o("safe");
		else o("warning");
	}
}