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>

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

using namespace std;

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

	rep(i,n)
	{
		double a,b;
		char c;
		cin >> a >> c >> b;

		double d = a*5 + b/12.0;	
		if(fabs(d-b) <= 5)
		{
			cout << "alert" << endl;
		}
		else if(15 <= fabs(d-b) && fabs(d-b) <= 30)
		{
			cout << "safe" << endl;
		}
		else if(d > b){
			double temp = fabs((60-d)-b);
			if(temp <= 5)
			{
				cout << "alert" << endl;
			}
			else if(15 <= temp && temp <= 30)
			{
				cout << "safe" << endl;
			}
			else
			{
				cout << "warning" << endl;
			}
		}
		else if(d <= b)
		{
			double temp = fabs((60-b)-d);
			if(temp <= 5)
			{
				cout << "alert" << endl;
			}
			else if(15 <= temp && temp <= 30)
			{
				cout << "safe" << endl;
			}
			else
			{
				cout << "warning" << endl;
			}
		}
	}
	return 0;
}

C++: #include <cstdio>
#define abs(x) ((x) < 0 ? -(x) : (x))
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main()
{
	int n; scanf("%d", &n);
	rep(i, n) {
		int h, m; scanf("%d:%d", &h, &m);
		int ah = h * 60 + m;
		int am = 12 * m;
		int diff = abs(ah - am);
		if (0 <= diff && diff < 60) puts("alert");
		else if (180 <= diff && diff <= 360) puts("safe");
		else puts("warning");
	}
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  for (int dataset=0; dataset<n; dataset++)
  {
    char dummy;
    int hour,minutes;
    cin >> hour >> dummy >> minutes;

    int hour_angle = hour * 30 + minutes / 2;
    int minutes_angle = minutes * 6;
    int angle_diff = hour_angle - minutes_angle;
    if ( angle_diff < 0 ) angle_diff = -angle_diff;

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

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

int main() {
	int n, h, m;
	float a1, a2;
	
	cin >> n;
	for(int i=0;i<n;++i){
		scanf("%d:%d",&h,&m);
		
		a1 = fabs((h * 30 + m / 2 ) - 6 * m);
		a2 = 360 - a1;
		
		if(a1 < 30 || a2 < 30){
			cout << "alert" << endl;
		}else if((a1 <= 180 && a1 >= 90) || (a2 <= 180 && a2 >= 90)){
			cout << "safe" << endl;
		}else{
			cout << "warning" << endl;
		}
	}
	
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair<char,int> P;

static const double eps = 10e-9;

string getAlert(double h,double m){
	double angleM = m * 6.0;
	double angleH = h * 30.0 + (m*6.0)/12.0;

	double dist = min(abs(angleH-angleM),360-abs(angleH-angleM));
	if(90 <= dist && dist <= 180) return "safe";
	else if(0 <= dist && dist < 30) return "alert";
	else return "warning";
}

int main(){
	int n;
	double h,m;
	while(~scanf("%d",&n)){
		for(int i=0;i<n;i++){
			scanf("%lf:%lf",&h,&m);
			cout << getAlert(h,m) << endl;
		}
	}
}

C++: #include <stdio.h>

#define ABS(X) ((X)<0?-(X):(X))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
    int n;
    int h,m;
    double angleH, angleM, dAngle;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%02d:%02d",&h, &m);
        //printf("%d, %d\n", h, m);
        angleM = 360*m/60.0;
        angleH = 360*h/12.0 + (360/12)*m/60.0;
        dAngle = ABS(angleM - angleH);
        dAngle = MIN(dAngle, 360.0-dAngle);
        if (dAngle < 30){
            puts("alert");
        } else if (dAngle < 90){
            puts("warning");
        } else {
            puts("safe");
        }
    }
    
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

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

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

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);
		// 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 <cmath>
#include <algorithm>
using namespace std;
int main(){
	int n,h,t;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d:%d",&h,&t);
		h=h*30;
		t=t*6;
		if(t<h)swap(t,h);
		if(0<=abs(h-t)&&abs(h-t)<30){
			cout<<"alert"<<endl;
		}else if(90<=abs(h-t)&&abs(h-t)<180){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<queue>
#include<map>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define fr first
#define sc second
#define INF 100
typedef pair<int,int>Pt;
int main(){
  int n;
  double H,M,hh,mm,mini;
  scanf("%d",&n);
  while(n--){
    scanf("%lf:%lf",&hh,&mm);
    H = hh * 30.0 + mm * 0.5;
    M = mm * 6.0;
    mini = fabs(H - M);
    if(H<M) H += 360.0;
    else M += 360.0;
    mini = min(mini,fabs(H-M));

    if(mini<30) cout << "alert" << endl;
    else if(mini>=90) cout << "safe" << endl;
    else cout << "warning" << endl;
  }
}

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

#define DEBUG(x) // cerr << #x << " = " << x << endl

const double EPS = 1e-8;

double deg_long(int hh, int mm) {
    hh %= 12;
    long double deg = (1.0 * 360) * hh / 12;
    deg += (1.0 * 360 / 12) * mm / 60;
}

double deg_short(int mm) {
    double deg = 1.0 * 360 * mm / 60;
}

int main() {
    int N; scanf("%d", &N);
    while(N--) {
        int hh, mm; scanf("%d:%d", &hh, &mm);
        double degA = deg_long(hh, mm);
        double degB = deg_short(mm);
        double diff = abs(degA - degB);
        diff = min(diff, abs((degA + 360) - degB));
        diff = min(diff, abs(degA - (degB + 360)));
        diff = min(diff, abs((degA + 360) - (degB + 360)));
        if (diff < 30 - EPS) puts("alert");
        else if(90 - EPS < diff) puts("safe");
        else puts("warning");
    }
}