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<cmath>
using namespace std;

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		int a,b; char c;
		
		cin>>a>>c>>b;
//		cout<<a<<" "<<b<<endl;
		double A =(double)a*30+b*0.5;
		double B =(double)b*6;
		
		double judge =(int)abs(A-B);
//		if(180<judge)judge = 360.0 - judge;
//		cout<<judge<<endl;
	
		cout<<a<<" "<<b<<" "<<judge<<endl;
		if(0<=judge && judge<30)cout<<"alert"<<endl;
		else if(90<=judge && judge<=180)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int abs(int a){
	return (a<0)?-a:a;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		int h,m,hp,mp;
		scanf("%02d:%02d",&h,&m);
		hp=h*60+m;
		mp=m*12;
		if((int)abs(mp-hp)%(60*12)*360<(60*12)*30) cout<<"alert\n";
		else if((int)abs(mp-hp)%(60*12)*360>=(60*12)*90&&(int)abs(mp-hp)%(60*12)*360<=(60*12)*180) cout<<"safe\n";
		else cout<<"warning\n";
	}
	return 0;
}

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;
        double ans=min(fabs(hh-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;
int a,b,c,d;
char ch;
int main(){
  cin>>n;
  while(n--){
    cin>>h>>ch>>m;
    a=h*30+m/12;
    b=m*6;
    //cout << a<< ' '<<b<<endl;
   
    c=max(a,b)-min(a,b);
    if(c>180)c=180-c;

    //cout<<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 tm = 360.0 * m / 60.0;
		double th = 360.0 * (h / 12.0 + m/60.0/12.0);
		double t = abs(th - tm);
		if (t > 180)
			t = 360 - t;

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

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n,h,s;
  double a,b,ans;
  cin>>n;
  while(n--){
    scanf("%d:%d",&h,&s);
    b=s*6;
    a=h*30+30*b/360;
    ans=abs(a-b);
    if(ans>180)ans=360-ans;
    if(0<=ans&&ans<30)cout<<"alert"<<endl;
    else if(90<=ans&&ans<=180)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }
  return 0;
}

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

string func(int s, int l){
	int a = l * 180 / 60;
	int b = s * 180 / 12 + l / 4;
	if(30 <= abs(a - b)){
		if(90 <= abs(a -b))return "safe";
		return "warning";
	}else return "alert";
	cout << a  << " " << b;
	return "a";
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		cout << func(s, l) << endl;
	}
	return 0;
}

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

int main(){
	int n;
	scanf("%d", &n);
	for(int i=0 ; i < n ; i++ ){
		int h, m;
		scanf("%d:%d", &h, &m);
		double s = h * 30.0 + m / 2.0 ;
		double l = m * 6.0 ;
		if( l < s ){
			swap( l , s );
		}
		double d = min( l-s , s-l+360.0 );
		if( d < 30.0 ){
			puts("alert");
		}else if( d < 90.0 ){
			puts("warning");
		}else{
			puts("safe");
		}
	}
}

C++: #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    rep(_,n){
        char a,b,c,d; char g;
        cin>>a>>b>>g>>c>>d;
        int l=(c-'0')*10+(d-'0');
        int s=(a-'0')*10+(b-'0');
        l*=6;
        s*=30;
        if(0<=abs(l-s)%360&&abs(l-s)%360<=30)cout<<"alert"<<endl;
        else if(90<=abs(l-s)%360&&abs(l-s)%360<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


#define reps(i,f,n) for(int i = f; i < int(n); i++)
#define rep(i,n) reps(i,0,n)

#define PII pair<int,int>
#define PP pair< int,PII >


using namespace std;



int main(){
	int n;
	int h,m;
	scanf("%d", &n);
	rep(i,n){
		int flag = 0;
		scanf("%d:%d", &h, &m);
		h = 30*h;
		h += m/2;
		m = m*6;
		
		int ha = (h+331)%360;
		rep(i,59){
			if(ha%360 == m){
				flag = 1;
			}
			ha++;
		}
		
		int hs = (h+90)%360;
		rep(i,181){
			if(hs%360 == m){
				flag = 2;
			}hs++;
		}
		
		if(flag == 1){
			cout << "alert" << endl;
		}else if(flag == 2){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
	
	return 0;
}

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

main(){
  int tcase; cin >> tcase;
  char ch; 
  double h, m, diff;
  for ( int i = 0; i < tcase; i++ ){
    cin >> h >> ch >> m;
    h = 30.0*h + m/2.0;
    m = 6.0*m;
    diff = max(h, m) - min(h, m);
    diff = min(diff, 360-diff);
    if ( 0 <= diff && diff < 30 ) cout << "alert" << endl;
    else if ( 90 <= diff && diff <= 180 ) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
}