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 <bits/stdc++.h> // only for GCC
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

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

  REP(i, n) {
    string s;
    cin >> s;
    int h = (s[0]-'0') * 10 + (s[1]-'0');
    int m = (s[3]-'0') * 10 + (s[4]-'0');

    double angleh = h*30 + m/60 * 30;
    double anglem = m * 6; 

    int ans;
    if(angleh > anglem) ans = angleh - anglem;
    else ans = anglem - angleh;

    if(ans > 180) {
      if(angleh > anglem) ans = 360-angleh + anglem;
      else ans = 360-anglem + angleh;
    }

    if(0 <= ans && ans <= 30) cout << "alert" << endl;
    else if(90 <= ans && ans <= 180) cout << "safe" << endl;
    else cout << "warning" << endl;
  }  
}

C++: #include<iostream>

using namespace std;

double topos(int in){
  return in * 0.2;
}

void solve(double h, double m){
  if(h < m) swap(h,m);
  if(h - m < 1.0) cout << "alert" << endl;
  else if(h - m < 3.0) cout << "warning" << endl;
  else cout << "safe" << endl;
}

int main(){
  int in;
  cin >> in;
  for(int i = 0; i < in; i++){
    int hour,minite;
    char trash;
    cin >> hour >> trash >> minite;
    //cout << hour << " " << trash << " " << minite<<endl;
    double pos = topos(minite);
    solve((double)hour,pos);
  }
  return 0;
}

C++: #include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n;
    cin>>n;
    while(n--){
        int h,m;
        scanf("%d:%d",&h,&m);
        double h_angle,m_angle;
        h_angle = h/12.0 + m/720.0;
        m_angle = m/60.0;
        double d = fabs(h_angle - m_angle);
        if(d - (1.0/6) < 1e-8)cout<<"alert"<<endl;
        else if(d - (1.0/4) < 1e-8)cout<<"warning"<<endl;
        else cout<<"safe"<<endl;
    }


    return 0;
}

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

using namespace std;

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

	double h, m;
	while (n--){
		scanf("%lf:%lf", &h, &m);
		double hh = 30 * h + 0.5 * m;
		double mm = 6 * m;
		// printf("hour angle %Lf\n", hh);
		// printf("minute angle %Lf\n", mm);
		double diff = abs(hh - mm);
		if (180 < diff) diff = 360 - diff;
		// 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>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<string>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstring>
#include<stack>
#include<functional>
using namespace std;

signed main(){
	int N,H,M;
	cin>>N;
	for(int i=0;i<N;i++){
		scanf("%d:%d",&H,&M);
		double d;
		d = abs(360.0*(H%12)/12.0-360.0*M/60.0);
		if(d>180.0) d = 360.0-d;
		if(d<30) puts("alert");
		else if(90<=d && d<=180) puts("safe");
		else puts("warning");
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cmath>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n; cin >> n;
    rep(i,n){
        int h,m;
        scanf("%d:%d",&h,&m);
        h=h*60+m;
        m*=720/60;
        int dt=min(abs(h-m),(h+720-m));
        // cout << dt << endl;
        string ans;
        if(dt<60*2) ans = "alert";
        else if(dt>=60*3) ans = "safe";
        else ans = "warning";
        cout << ans << endl;
    }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	int n; cin >> n;
	rep(i, 0, n) {
		double H = 360, M = 360;
		string s; cin >> s;
		double h = stoi(s.substr(0, 2)), m = stoi(s.substr(3, 2));
		M = M*m / 60;
		H = H*h / 12 + m / 60 * 30;
		double a;
		if (H < M)swap(H, M);
		a = min(H - M, abs(H - M - 360));
		if (a < 30)cout << "alert" << endl;
		else if (a < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    for(int p=0; p < n; p++){
        int h, m;
        scanf("%d:%d", &h,&m);
        double hAngle = (360/12)*h + (360.0/12/60)*m;
        double mAngle = (360/60)*m;
        double angle = abs(hAngle-mAngle);
        if(0 <= angle && angle < 30) cout << "alert" << endl;
        else if(90 <= angle && angle <= 180) cout << "safe" << endl;
        else cout << "warning" << endl;
    }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	int n, h, m;
	char c;
	cin >> n;
	rep(i,n) {
		cin >> h >> c >> m;
		double x = 30.0*(h+m/60.0);
		double ret = abs(x-6*m) < 180 ? abs(x-6*m) : 360-abs(x-6*m);
		if(0 <= ret && ret < 30) cout << "alert" << endl;
		else if(90 <= ret && ret <= 180) cout << "safe" << endl;
		else cout << "warning" << endl;
	}
	return 0;
}