#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>
#include <sstream>
#include <math.h>
#include <queue>
#include <stack>
#include <math.h>
#include <string.h>


using namespace std;


int main(){
    int n;
    cin>>n;
    for(int i=0; i<n; i++){
        string temp;
        cin>>temp;
        int h=(temp[0]-'0')*10+(temp[1]-'0');
        int m=(temp[3]-'0')*10+(temp[4]-'0');
        
        double h_angle;
        h_angle = 360.0/12.0 * h + (360.0/12.0)/60.0 * m;
        double m_angle;
        m_angle = 360.0/60.0 * m;
        
        double angle = max(h_angle,m_angle)-min(h_angle,m_angle);
        if(angle>180.0)angle=360.0-angle;
        
        if(angle<30.0)cout<<"alert"<<endl;
        else if(angle>=90.0)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;

    }
}