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

int main()
{
  int n;
  string s;
  double x,y,a,b,ans=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    x=(s[0]-'0')*10+(s[1]-'0');
    y=(s[3]-'0')*10+(s[4]-'0');
    a=(x+y/(60))*5;
    b=y;
    ans=min(6*abs(a-b),360-6*abs(a-b));

    if(ans<30)cout<<"alert"<<endl;
    else if(90<=ans && ans<=180)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }

  return 0;
}