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 <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

main(){
  int n;
  cin>>n;
  while(n--){
    long double hh,mm;
    scanf("%Lf:%Lf",&hh,&mm);
    hh=30*hh+mm*0.5;
    
    mm*=6;
    //cout<<hh<<":"<<mm<<endl;
    long double diff=abs(hh-mm);
    if(mm>hh)diff=abs(mm-hh);
    if(diff>180)diff=360-diff;

    if(diff<30)puts("alert");
    else if(diff>=90)puts("safe");
    else puts("warning");
  }
}

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

int main() {
	int a,b,n;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%d%c%d",&a,&c,&b);
	a*=30; b*=6;
	b=(b-a+360) % 360;
	b= b >180 ? 360-b : b;
	if (b=<30) cout << "alert" << endl; else
		if (b>=90) cout << "safe" << endl; else cout << "warning" << endl;
	}
return 0;
}

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

int main(void){
	int n;
	double h,m;
	double ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&m);
		h=h*30+m/4;
		m=m*6;
		ans=abs(h-m);
		if(ans<30 || ans>330)cout << "alert" << endl;
		else if(90<=ans && ans<=270)cout << "safe" << endl;
		else cout << "warning" << endl;
	}
    return 0;
}

C++: #include "bits/stdc++.h"

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main(){
	int n;
	cin>>n;
	rep(i,n){
		char ch;
		int h,m;
		cin>>h>>ch>>m;


		if(360-abs(30*h+h/2.0-6*m)<30 || abs(30*h+h/2.0-6*m)<30)cout<<"alert"<<endl;
		else if(90<=abs(30*h+h/2.0-6*m) && abs(30*h+h/2.0-6*m)<=270)cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
	return 0;
}

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

C++: #include <cstdio>
#include <algorithm>

using namespace std;

int h, m;

void solve(){
    // ツ陳キツ針
    double l = m * 6;
    
    // ツ短ツ針
    double s = h * 30 + m / 2.0;
    
    if(l < s){
        swap(l, s);
    }
    
    // ツ角ツ度ツづーツ仰づ淞づゥ
    double diff = min(l - s, s - l + 360);
    
    if(diff < 30){
        printf("alert\n");
    }
    
    else if(diff < 90){
        printf("warning\n");
    }
    
    else {
        printf("safe\n");
    }
}

int main(){
    int n;
    
    scanf("%d", &n);
    
    for(int i = 0; i < n; ++i){
        scanf("%d:%d", &h, &m);
        solve();
    }
    
    return 0;
}

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

int main(void){
	int n;
	double h,m;
	double ans;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&m);
		h=h*30+m/4;
		m=m*6;
		ans=abs(h-m);
		if(ans<30 || ans>330)cout << "alert" << endl;
		else if(90<=ans && ans<=270)cout << "safe" << endl;
		else cout << "warning" << endl;
	}
    return 0;
}

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;
        double l=(c-'0')*10+(d-'0');
        double  s=(a-'0')*10+(b-'0');
        l*=6;
        s*=30;
        s+=(l)/72;
        double val=min(abs(l-s),360-abs(l-s));
        if(EPS<=val&&val<=30)cout<<"alert"<<endl;
        else if(EPS<=val-90&&val<=180)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

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)*6;
    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 <string>
#include <stdlib.h>
#include <iostream>
#include <math.h>

#define BUFSIZE 10
using namespace std;

int main(void){
    int c;
    char buf[BUFSIZE];
    cin >> buf;
    int times = atoi(buf);

    for(int i = 0; i < times; i++){
      cin >> buf;
      int hr, mn;
      double shrt, lng;
      buf[2] = '\0';
      hr = atoi(buf);
      mn = atoi(&buf[3]);
      shrt = hr * 30.0 + mn * 0.5;
      lng = mn * 6.0;
      double deg = fabs(lng - shrt);
      deg = (deg >180) ? (360-deg) : deg;
      if(deg < 30) cout << "alert" << endl;
      else if(deg < 90) cout << "warning" << endl;
      else cout << "safe" << endl;
    }
    return 0;
}