#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n)           REPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
typedef unsigned long long ull;

int main(){
    int n;
    cin >> n;       // 10^4
    REP(i,n){
        int h, m; char c;
        cin >> h >> c >> m;   // hh:mm

        int th1 = 3600/12*h + 300/60*m;
        int th2 = 3600/60*m;
        int th_diff = abs(th1-th2);
        if(th_diff > 1800) th_diff = 3600-th_diff;
        //printf("th1 = %d, th2 = %d\n", th1, th2);
        if(th_diff < 300){
            cout << "alert" << endl;
        } else if(th_diff >= 900){
            cout << "safe" << endl;
        } else {
            cout << "warning" << endl;
        }
    }
    return 0;
}