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>
using namespace std;
int main() {
	double n=0.5,m=6,n2=30;
	int a,b,n4,e=0;
	cin>>n4;
	for(int i=0;i<n4;i++){
		string d;
		cin>>d;
		d+=":";
		string h;
		e=0;
		for(int j=0;j<d.length();j++){
			if(d[j]==':'){
				if(e==0)
					a=atoi(h.c_str());
				else
					b=atoi(h.c_str());
				h="";
				e++;
			}
			else
				h+=d[j];
		}
		double n3,m3;
		n3=0;
		n3+=(a*n2+b*n);
		m3=0;
		m3+=b*m;
		double c=n3-m3;
		if(c<0)
			c=0-c;
		if(360-c<c){
			c=360-c;
		}
		if(c>=90&&c<=180)
			printf("safe\n");
		else if(c>=0&&c<30)
			printf("alert\n");
		else
			printf("warning\n");
	}
}

C++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#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 each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n; cin >> n;
	while (n--) {
		string s; cin >> s;
		double lo = stoi(s.substr(0, 2)) * 5 / 60.0 * 360;
		double sh = stoi(s.substr(3, 2)) / 60.0 * 360;
		double dif = min(fabs(lo - sh), 360.0 - fabs(lo - sh));
		dump(lo); dump(sh); dump(dif);
		if (dif < 30.0)cout << "alert" << endl;
		else if (dif < 90)cout << "warning" << endl;
		else cout << "safe" << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define all(a) (a).begin(), (a).end()

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
	int n;
	cin >> n;
	rep(q, n){
		string s;
		cin >> s;
		int h, m;
		h = stoi(s.substr(0, 2)); m = stoi(s.substr(3, 2));
		double a, b;
		a = 360/(60./m); b = 360/(12./h) + 30/(60./m);
		if(abs(a-b) < 30 || abs(abs(a-b)-360) < 30) cout << "alert" << endl;
		else if(abs(a-b) < 90 || abs(abs(a-b)-360) < 90) cout << "warning" << endl;
		else cout << "safe" << endl;
	}
}

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

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

int main() {
	int n;
	cin >> n;
	while (n--) {
		int h, m;
		scanf("%d:%d", &h, &m);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = min(abs(angle1 - angle2), 360.0 - abs(angle1 - angle2));
		
		if (div >= 0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

int main(void) {
  int i,j;
  int n;
  cin>>n;
  rep(i,n){
    int h,m;
    scanf("%d:%d",&h,&m);
    double a=30*h+m/2.0;
    double b=6*m;
    if(a>b)swap(a,b);
    if(b-a<30 || a+360-b<30)cout<<"alert"<<endl;
    else if(b-a>=90 && a+360-b>=90)cout<<"safe"<<endl;
    else cout<<"warning"<<endl;
  }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
void check(int h,int m)
{
	double v=abs(30.0*h-5.5*m);
	v=min(v,360-v);
	if(v<30)cout << "alert" << endl;
	else if(v<90)cout << "warning" << endl;
	else cout << "safe" << endl;
	return;
}
int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin >> s;
		int h,m;
		h=(s[0]-'0')*10+(s[1]-'0');
		m=(s[3]-'0')*10+(s[4]-'0');
		check(h,m);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,h,m;
char com;
double s,l;

int main(){
	cin>>n;
	while(cin>>h>>com>>m){
		s=6.0*m;
		l=0.5*(h*60+m);
		double a=l-s;
		if(a<0)a*=-1;
		a=min(a,360.0-a);
		if(a<30)cout<<"alert"<<endl;
		else if(a<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}
}

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+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<cmath>

using namespace std;

double topos(int in,int num){
  if(num) return in * 6;
  return in*30;
}

void solve(double h, double m){
  double judge =fabs(h-m);
  if(judge > 180) judge = 180 - judge;
  //cout << judge << endl;
  if(judge < 30) cout << "alert" << endl;
  else if(judge < 90) 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,1);
    double posh = topos(hour,0);
    solve(posh+minite/2,pos);
  }
  return 0;
}