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<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        rep(i,n){
            double hour, mini;
            scanf("%lf%*c%lf", &hour, &mini);
            double angle = (hour * 360 / 12 + mini * 360 / 60 / 60) - (mini * 360 / 60);
            if(angle < 0) angle*= -1;
            if(angle >= 0 && angle < 30)
                cout << "alert" << endl;
            else if(angle >= 90 && angle <= 180)
                cout << "safe" << endl;
            else
                cout << "warning" << endl;
        }
    }
}

C++: #include<stdio.h>
#include<math.h>
int N,H,M;
double s,t,a;
int main()
{
	scanf("%d",&N);
	for(;N--;)
	{
		scanf("%d:%d",&H,&M);
		s=0.5*M+H*30;
		t=M*6;
		a=s-t<0?t-s:s-t;
		a=a<360-a?a:360-a;
		//printf("%lf\n",a);
		puts(a>=90?"safe":a<30?"alert":"warning");
	}
	return 0;
}

C++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	int n;
	cin>>n;
	int h,m;
	char co;
	for(int i=0;i<n;i++){
		double d=0;
	cin>>h>>co>>m;
		d=double(360)/12*h;
		d+=double(360)/12/60*m;
		d-=double(360)/60*m;
		d=abs(d);
		if(d>=0&&d<30)
			cout<<"alert"<<endl;
		else if(d>=90&&d<=180)
			cout<<"safe"<<endl;
		else
			cout<<"warning"<<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 getNum(string str, int pos) {
	int res = str[pos++] - '0';
	while (isdigit(str[pos])) {
		res = res * 10 + str[pos++] - '0';
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + angle1 / 30.0;
		double div = abs(angle1 - angle2);
		
		if (div >= 0.0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<algorithm>
int main(void)
{
	int n,h,m,a;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d:%d",&h,&m);
		h=h*60+m;
		m*=12;
		a=std::min(abs(h-m),std::min(abs(h+720-m),abs(h-720-m)));
		if(a<60)
			puts("alert");
		else if(a>=180)
			puts("safe");
		else puts("warning");
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	int t,h;
	double n,ans;
	char c;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d%c%d",&h,&c,&t);
		ans=float(h)*30+(0.5*float(t));
		ans+=float(t)*6;
		cout<<h<<" "<<t<<endl;
		if(h<t)swap(h,t);
		ans=h-t;
		if(ans>180)ans-=180;
		if(0.0<=ans&&ans<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=ans&&ans<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

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

int main()
{
  int n;
  string s;
  double x,y,a,b,ans=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s;
    x=(s[0]-'0')*10+(s[1]-'0');
    y=(s[3]-'0')*10+(s[4]-'0');
    a=(x+y/(60*12))*5;
    b=y;
    ans=min(6*abs(a-b),360-6*abs(a-b));
    if(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>
#include<cstdio>
using namespace std;
int a, b, n;
double d, e, f;
int main() {
	cin >> n;
	for (int i = 0; i < n;i++) {
		scanf("%d:%d", &a, &b);
		f = abs(a * 30 + b * 11.0 / 2.0);
		if (f > 180) { f = 360 - f; }
		if (f < 30) { cout << "alert" << endl; }
		else if (f < 90) { cout << "warning" << endl; }
		else { cout << "safe" << endl; }
	}
}

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(){
	int hh,mm;
	char c;
	int n;
	cin>>n;
	rep(i,n){
		cin>>hh>>c>>mm;
		hh*=30;mm*=6;
		if(abs(hh-mm)<=30)cout<<"alert";
		else if(90<=abs(hh-mm))cout<<"safe";
		else cout<<"warning";
		cout<<endl;
	}
}

C++: #include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int n;
    while(cin >> n){
        rep(i,n){
            double hour, mini;
            scanf("%lf%*c%lf", &hour, &mini);
            double angle = hour * 360 / 12 + mini * 360 / 60 / 60 - mini * 360 / 60;
            if(angle < 0) angle*= -1;
            if(angle >= 0 && angle < 30)
                cout << "alert" << endl;
            else if(angle >= 90 && angle <= 180)
                cout << "safe" << endl;
            else
                cout << "warning" << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int Tc; cin >> Tc;
  int H, M;
   
  while(Tc --) {
    scanf("%d:%d", &H, &M);
     
    int h = H*30.0 + M/2.0, m = M*6;
     
    int ang = abs(h - m);
    if(ang > 180) ang = 360 - ang;
    if(0 <= ang && ang < 30) {
      cout << "alert" << endl;
    }
    else if(90 <= ang && ang <= 180) {
      cout << "safe" << endl;
    }
    else cout << "warning" << endl;
  }
   
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	double h, m;
	char c;
	double a, b, d;
	for (int i = 0; i < n; i++) {
		cin >> h >> c >> m;
		b = 360.0 * m / 60.0;
		a = (360.0 * h / 12.0) + (30.0 * m / 60.0);
		d = fabs(a-b);
		d = min(d, 360.0-d);
		if (d < 30.0) {
			cout << "alert" << endl;
		} else if (d >= 90.0) {
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
	return 0;
}

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 getNum(string str, int pos) {
	int res = str[pos++] - '0';
	while (isdigit(str[pos])) {
		res = res * 10 + str[pos++] - '0';
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		string str;
		cin >> str;
		int h = getNum(str, 0), m = getNum(str, 3);
		
		double angle1 = m * 6.0, angle2 = h * 30.0 + m / 2.0;
		double div = abs(angle1 - angle2);
		
		if (div >= 0.0 && div < 30.0)
			puts("alert");
		else if (div >= 90.0 && div <= 180.0)
			puts("safe");
		else
			puts("warning");
	}
	return 0;
}