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 "stdafx.h"
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	double a,b,d;
	char c;
	cin >> n;
	for (;n>0;n--) {
	scanf("%lf%c%lf",&a,&c,&b);
	a= a>=12 ? a-12 : a;
	a=a*30+b*0.5; b*=6;
	if (a>b) { d=a; a=b; b=d;}
	b-=a;
	b= b>180 ? 360-b : b;
	if (b<30) cout << "alert" << endl; else
		if (b>=90) 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))*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<bits/stdc++.h>
using namespace std;
main(){
  int n;
  double a,b;
  cin>>n;
  while(n--){
    scanf("%lf:%lf",&a,&b);
    a*=5;
    a+=b/60;
    int y=abs(b-a),x=abs(60-b+a);
    if(min(y,x)<=5)cout<<"alert"<<endl;
    else if(min(y,x)<=15)cout<<"warning"<<endl;
    else cout<<"safe"<<endl;
  }
}

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

string func(int M, int H){
	/*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) {
      return "alert";
    }
    else if(90 <= ang && ang <= 180) {
      return "safe";
    }
    return "warning";
  }
}

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<string> result;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    int h, m;
    double rh, rm;
    scanf("%d:%d\n", &h, &m);
    // (m / 60 * 360) == (h * 6)                                                                                                                  
    rm = m * 6.0;
    // (h / 12 * 360) == (h * 6)                                                                                                                  
    rh = h * 30.0;
    rh += m * 0.5;
    double dis = rh - rm;
    dis *= (dis > 0 ? 1 : -1);
    if (0.0 <= dis && dis <= 30.0)
      result.push_back("alert");
    else if (90 <= dis)
      result.push_back("safe");
    else
      result.push_back("warning");
  }

  for (int i = 0; i < n; i++)
    cout << result[i] << endl;
  return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	float s, t;
	
	cin >> n;
	while(n--){
		scanf("%f:%f", &s, &t);
		
		s = s*30-5.5*t;
		if(s < 0){
			s = -s;
		}
		
		if(0 <= s && s < 30){
			cout << "alert" << endl;
		} else if(90 <= s && s <= 180){
			cout << "safe" << endl;
		} else {
			cout << "warning" << endl;
		}
	}
}

C++: #include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
//#define int long long
#define rep(i, n) for (int i=0; i<n; i++)
#define REP(n) rep(i, n)
using namespace std;

int n, hh, mm; 
char colon;
float tansin, tyousin, sa; 

signed main()
{
    cin >> n;

    REP(n)
    {   
        cin >> hh >> colon >> mm; 
        //printf("hh = %d, mm = %d\n", hh, mm);

        tansin = 30.0 * hh + 0.5 * mm; 
        tyousin = 6.0 * mm; 

        float saki = fmax(tansin, tyousin);
        float ato = fmin(tansin, tyousin);

        sa = fmin(saki - ato, 360.0 - saki + ato);
        //printf("sa = %f\n", sa);

        if (0.0 <= sa && sa < 30.0)
        {   
            cout << "alert" << endl;
        } else if (90.0 <= sa && sa <= 180.0) {
            cout << "safe" << endl;
        } else {
            cout << "warning" << endl;
        }   
    }   

    return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        vector<string> list = split(s,':');
        int h,m;
        h = stoi(list[0]);
        m = stoi(list[1]);

        int x,y;
        x = 60*m;
        y = 300*h+5*m;
        x%=3600;
        y%=3600;
        
        if( abs(x-y)<300 || abs(x-y)>3300 )cout<<"alert"<<endl;
        else if( 900<=abs(x-y) && abs(x-y)<=2700)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

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

int main(){
  int n;
  cin >> n;
  while(n--){
    int h, m;
    scanf("%d:%d", &h, &m);
    double H = (double)h * 30 + m*0.5;
    double M = (double)m * 6;
    
    double ans = abs(H-M);
    if(180 < ans) ans = 360.0 - 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 <bits/stdc++.h>
using namespace std;

int main(){
  int T;
  cin>>T;
  while(T--){
  int h,m;
  scanf("%d:%d",&h,&m);
  double A,B;
  A=360*(h/12.0);
  B=360*(m/60.0);
  double r=abs(A-B);
  if(r>180)r=360-r;
  if(r<=30)cout<<"alert"<<endl;
  else if(r<90)cout<<"warning"<<endl;
  else cout<<"safe"<<endl;
  
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		int h;
		int m;
		double shortHand, longHand;
		double deg;
		cin>>h;cin.ignore(1);cin>>m;
		longHand = m*6;
		shortHand = 30*h+0.5*m;
		deg = fabs(shortHand-longHand);
		if(deg>180.0)
			deg = 360.0-deg;
		if(deg<30.0){
			cout<<"alert\n";
		}else if(deg>=90.0&&deg<=180.0){
			cout<<"safe\n";
		}else{
			cout<<"warning\n";
		}
	}
	return 0;
}

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);
		int dm=m*12;
		int dh=h*60+m;
		int a=abs(dm-dh);
		cout<<(a<60?"alert":a>=180?"safe":"warning")<<endl;
	}
}

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

string func(int s, int l){
	int a = l * 6;
	int b = s * 30 + l / 2;
	int s = abs(a - b);
	if(s > 180)s = 360 - s;
	if(30 <= s){
		if(90 <= s)return "safe";
		return "warning";
	}else return "alert";
	cout << a  << " " << b;
	return "a";
}

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