#include<iostream>
#include<cmath>

using namespace std;

void StringHandle(string, int&, int&);
int Atoi(string);

int main(){
  int i, n, hour, minute;
  double h_radian, m_radian, radian;
  string clock;

  cin >> n;

  for(i=0; i<n; ++i){
    cin >> clock;
    StringHandle(clock, hour, minute);

    h_radian = (60*hour + minute) * M_PI / 360;
    m_radian = minute * M_PI / 30;
    radian = h_radian - m_radian;
    if(radian < 0) radian = -radian;
    if(radian > M_PI) radian = 2*M_PI - radian;

    if(radian < M_PI/6)
      cout << "alert" << endl;
    else if(radian >= M_PI/2)
      cout << "safe" << endl;
    else
      cout << "warning" << endl;
  }

  return 0;
}

void StringHandle(string s, int& h, int& m){
  string s1, s2;
  copy(s.begin(), s.begin()+2, back_inserter(s1));
  copy(s.begin()+3, s.end(), back_inserter(s2));
  h = Atoi(s1);
  m = Atoi(s2);
}

int Atoi(string s){
  int one, ten;
  ten = s[0] - 48;
  one = s[1] - 48;
  return 10*ten + one;
}