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 <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	double n,h,t;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%lf:%lf",&h,&t);
		h=h*30+(0.5*t);
		t=t*6;
		if(h<t)swap(t,h);cout<<h<<" "<<t<<endl;
		if(0.0<=(h-t)&&(h-t)<=30.0){
			cout<<"alert"<<endl;
		}else if(90.0<=(h-t)&&(h-t)<180.0){
			cout<<"safe"<<endl;
		}else{
			cout<<"warning"<<endl;
		}
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	int n;
	
	cin>> n ;
	for(int i = 0 ; i < n ; i++){
		int a,b; char c;
		cin>>a>>c>>b;
		
		b*=60;
		a=a*12+b*0.5;
		
	//	cout<<a<<" "<<b<<" "<<(a-b)%180<<endl;
		if((a-b)%180<0)cout<<"alert"<<endl;
		else if((a-b)%180==0)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}

}

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }

int main()
{
  // 1分で進む角度で考える
  // 長針 1分 => 6度
  // 短針 60分 => 30度 :: 1分 => 0.5度
  rep(i, in()){
    double h, m;
    scanf("%lf:%lf", &h, &m);
    h = h * 30 + m * 0.5;
    m *= 6;
    double deg = abs(h - m);
    if (180 < deg) deg = 360.0 - deg;
    if (0 <= deg && deg < 30){
      puts("alert");
    }
    else if (90 <= deg && deg <= 180){
      puts("safe");
    }
    else {
      puts("warning");
    }
  }
  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 = min(abs(hh - mm), abs(mm - hh));
		// 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 <cmath>
#include <cstdio>

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) + 30 * (m / 60);
		long double mm = 360 * (m / 60);
		// printf("hour angle %Lf\n", hh);
		// printf("minute angle %Lf\n", mm);
		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 <cstdlib>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
#include <sstream>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second
#define mkp make_pair

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

template <class T>
void initvv(vector<vector<T> > &v,int a,int b, const T  &t = T()){
	v.assign(a,vector<T>(b,t));
}

//v.erase(unique(v.begin(),v.end()),v.end());


int main(){
	int n;
	cin>>n;
	rep(i,n){
		int a,b;
		char t;
		cin>>a>>t>>b;
		long double aa=0.0,bb=0.0;
		aa=a*30.0;
		aa+=b/2.0;
		bb=b*6.0;
		long double ans=360.0;
		ans=min(abs(aa-bb),ans);
		ans=min(abs(aa+360-bb),ans);
		ans=min(abs(aa-bb-360),ans);
		if(0.0<=ans&&ans<30.0) cout<<"alert\n";
		else if(30.0<=ans&&ans<90.0) cout<<"warning\n";
		else cout<<"safe\n";
	}
}

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

string func(int H, int M){
	/*double a = l * 6;
	double b = s * 30.0 + l / 2.0;
	int m = abs(a - b);
	if(180 < m)m = 360 - m;
	if(0 <= m && m < 30)return "alert";
	if(90 <= m && m <= 180)return "safe";
	return "waring";
	if(m > 180)m = 360 - m;
	if(30 <= m){
		if(90 <= m)return "safe";
		return "warning";
	}
	return "alert";*/
	double 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;
}

int main(){
	int n, s, l;cin >> n;
	char c;
	while(n--){
		cin >> s >> c >> l;
		func(s, l);
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>

using namespace std;

inline int toInt(string s) { stringstream ss(s); int x; ss >> x; return x; }

int main() {
  int n;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    int sh = toInt(s.substr(0, 2));
    int lg = toInt(s.substr(3));
    double argSh = sh*5*6;
    double argLg = lg*6; argSh += argLg/12;
    
    double hen = abs(argSh-argLg);
    hen = min(hen, 360.0-hen);
    if(0<=hen && hen<30) cout << "alert" << endl;
    else if(90<=hen && hen<=180) cout << "safe" << endl;
    else cout << "warning"<< endl;
  }
  
  return 0;
}

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main() {

  int n;
  cin>> n;
  while(n--) {
    int l_hand, s_hand;
    double l_angle, s_angle;
    double angle;

    scanf("%d:%d",&l_hand, &s_hand);
    l_angle = (double)l_hand*30 + (double)s_hand*0.5;
    s_angle = (double)s_hand*6;
    angle = abs(l_angle-s_angle);
    angle = min(angle, 360-angle);

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

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
using namespace std;
int main(){
  int n;
  cin>>n;
  while(n--){
    int a,b;
	char d;
	cin>>a>>d>>b;
	double h=abs(30.0*a-5.5*b);
	//cout<<h<<endl;
	if(h<30||360-h<30)cout<<"alert"<<endl;
	else if(h>=90&&h<=270)cout<<"safe"<<endl;
	else cout<<"warning"<<endl;
  }
}

C++: #include<iostream>
#include<ios>
#include<algorithm>
using namespace std;
int n;
main()
{
	cin>>n;
	for(;n--;)
	{
		int h,m;
		scanf("%d:%d",&h,&m);
		double dm=m*6;
		double dh=h*30+m*1./2;
		double a=abs(dm-dh);
		cout<<(a<30?"alert":a>=90?"safe":"warning")<<endl;
	}
}