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;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
int main(){
	double hh,mm;
	char c;
	int n;
	cin>>n;
	rep(i,n){
		cin>>hh>>c>>mm;
		hh=30*hh+0.5*mm;mm*=6;
//		cout<<hh<<"-"<<mm<<"="<<abs(hh-mm)<<" "<<abs(hh-mm);
		if(abs(hh-mm)<=30)cout<<"alert";
		else if(90<=abs(hh-mm)&&abs(hh-mm)<=180)cout<<"safe";
		else cout<<"warning";
		cout<<endl;
	}
}

C++: #include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
	int n;
	int hour,minute;
	char d;
	double kakuh,kakum,sa;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> hour >> d >> minute;
		kakuh = 30.0 * hour + minute * 0.5;
		kakum = 6.0 * minute;
		sa = abs(kakuh-kakum);
		if (sa > 180.0) {
			sa = sa - 180;
		}
		if (sa <30.0) {
			cout << "alert" << endl;
		} else if (sa >= 90.0) {
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	int n,h,w,x;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		h=10*(s[0]-'0')+s[1]-'0';
		w=10*(s[3]-'0')+s[4]-'0';
		h*=30,w*=6;
		if(h>w)x=h-w;
		else x=w-h;
		if(x>180)x=360-x;
		if(x>=90)cout<<"safe"<<endl;
		if(x<=30)cout<<"alert"<<endl;
		if(x>30&&x<90)cout<<"warning"<<endl;
	}
	return 0;
}