#include <iostream>
#include <cstdio>

int main(){
	//Input
	int N;
	std::cin >> N;

	int H, M;
	while(N--){
		scanf("%d:%d",&H,&M);
		//Processing
		//ツ角ツ度ツづーツ仰づ淞づゥ
		double aH = 30 * H, aM = 6 * M, a;
		std::cout << aH << "," << aM << std::endl;
		if(aH > aM){
			a = aH - aM;
		}
		else{
			a = aM - aH;
		}

		//ツ甘ォツ個ッツつウツづーツ板サツ津ィ
		std::string res;
		if(a >= 0 && a <= 30){
			res = "alert";
		}
		else if(a >= 90 && a <= 180){
			res = "safe";
		}
		else{
			res = "warning";
		}

		std::cout << res << std::endl;
	}
}