Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < n; i++ {
		scanner.Scan()
		input := strings.Split(scanner.Text(), ":")
		h, _ := strconv.Atoi(input[0])
		m, _ := strconv.Atoi(input[1])
		H, M := (30*h+(m/2))*2, (6*m)*2
		if m&1 == 1 {
			H++
		}
		a := H - M
		if a < 0 {
			a = -a
		}
		a2 := 720 - a
		if a2 < a {
			a = a2
		}
		if a < 60 {
			fmt.Println("alert")
		} else if a >= 180 && a <= 360 {
			fmt.Println("safe")
		} else {
			fmt.Println("warning")
		}
	}
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n, h, m;

int main(){
	cin >> n;
	REP(i, n){
		scanf("%d:%d", &h, &m);
		double s = (double)h * 30.0 + (double)m*0.5, l = (double)m * 6.0;
		if (fabs(l - s) - 30.0 < -EPS)cout << "alert" << endl;
		else if (fabs(l - s) - 90 < -EPS)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
	long n;
	cin>>n;
	for(int i=0;i<n;i++){
		int hh,mm;
		char cc;
		cin>>hh>>cc>>mm;
		double tyousin=mm*6;
		double tansin=hh*30+mm*0.5;
		double sita=abs(tyousin-tansin);
		if(0<=sita<30)cout<<"alert"<<endl;
		else if(sita>=90 && sita<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>

using namespace std;

int main(void)
{
	int n;
	cin >> n;

	long double h, m;
	while (n--){
		scanf("%Lf:%Lf", &h, &m);
		long double hh = 360 * (h / 12);
		long double mm = 360 * (m / 60);
		long double diff = abs(hh - mm + 1);
		// cout << diff << endl;
		if (0 <= diff && diff <= 30){
			cout << "alert" << endl;
		}
		else if (90 <= diff && diff <= 180){
			cout << "safe" << endl;
		}
		else {
			cout << "warning" << endl;
		}
	}

	return 0;
}

C++: #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;
    }
}

C++: #include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++){
        double h,m;
        scanf("%lf:%lf",&h,&m);
        double totalm=h*60+m;
        double hh=totalm/2,mm=m*6;
        while(359.999999<hh)hh-=360;
        //printf("[%f][%f]\n",hh,mm);
        double ans=min(fabs(hh-mm),min(fabs(hh+360-mm),fabs(hh-360-mm)));
        if(ans<30)puts("alert");
        else if(ans<90)puts("warning");
        else puts("safe");
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n,h,m;
double a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+m/2.0;
    b=m*6;
      
     
    c=max(a,b)-min(a,b);
    if(c>180){
      c=360-c;
    }
  
    //cout << a<< ' '<<b<<' '<<c<<endl;
      
    if(0<=c&&c<30){
      cout<<"alert"<<endl;
    }else if(90<=c&&c<=180){
      cout<<"safe"<<endl;
    }else{
      cout<<"warning"<<endl;
    }
      
  }
  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int h, m;
		scanf("%d:%d", &h, &m);
		double t = abs((h/12.0+m/60.0/12) - m/60.0);
		if (t > 0.5)
			t = 1 - t;
		t *= 360;

		if (t < 30)
			puts("alert");
		else if (t < 90)
			puts("warning");
		else
			puts("safe");
	}

	return 0;
}

C++: #import<cstdio>
int main(){int n,h,m;scanf("%d",&n);for(;n--;){scanf("%d:%d",&h,&m);double s=h*30+m/2.,l=m*6,t,d;l<s?t=l,l=s,s=t:0;d=s-l+360;l-s<d?d=l-s:0;d<30?puts("alert"):d<90?puts("warning"):puts("safe");}}

C++: #include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n,h,m;
	scanf("%d",&n);
	for(;n--;){
		scanf("%d:%d",&h,&m);
		double s=h*30+m/2.,l=m*6,t,d;
		l<s?t=l,l=s,s=t:0;
		d=min(l-s,s-l+360);
		if(d<30){
			puts("alert");
		}else if(d<90){
			puts("warning");
		}else{
			puts("safe");
		}
	}
}

C++: #include<iostream>
using namespace std;
int main(){
long n,h,m,i,y;
char c;
cin>>n;
for(i=0;i<n;i++){
cin>>h>>c>>m;
y=m*11-h*60;
if(y<0)y=-y;
if(y>360)y=720-y;
if(y<60)cout<<"alert"<<endl;
else if(y>=180)cout<<"safe"<<endl;
else cout<<"warning"<<endl;
}
return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

std::vector<std::string> split(const std::string &s, const std::string &delim) {
  using string = std::string;
  std::vector<string> v;
  string::size_type pos = 0;
  while (pos != string::npos) {
    string::size_type p = s.find(delim, pos);
    if (p == string::npos) {
      v.push_back(s.substr(pos));
      break;
    }
    v.push_back(s.substr(pos, p - pos));
    pos = p + delim.size();
  }
  return v;
}

main {
  int n;
  cin >> n;
  while (n--) {
    double h, m;
    {
      string s;
      cin >> s;
      vs v = split(s, ":");
      h = stod(v[0]);
      m = stod(v[1]);
    }
    double ah = h * 30 + m / 2, am = m * 6;
    double arg = min(abs(ah - am), 360.0 - abs(ah - am));
    if (0.0 <= arg && arg < 30.0) cout << "alert" << endl;
    if (30.0 <= arg && arg < 90.0) cout << "warning" << endl;
    if (90.0 <= arg && arg <= 180.0) cout << "safe" << endl;
  }
}