#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        vector<string> list = split(s,':');
        int h,m;
        h = stoi(list[0]);
        m = stoi(list[1]);

        int x,y;
        x = 60*m;
        y = 300*h+5*m;
        x%=3600;
        y%=3600;
        
        if( abs(x-y)<300 || abs(x-y)>3300 )cout<<"alert"<<endl;
        else if( 900<=abs(x-y) && abs(x-y)<=2700)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}