#include<iostream>
using namespace std;
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    while(n--){
        int t,m;
        (cin>>t).ignore()>>m;
        t*=5;
        int dif=max(t,m)-min(t,m);
        dif=min(dif,60-dif);
        if(dif<=5)cout<<"alert"<<endl;
        else if(dif>=15)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}