uses crt;
var i,n:word;
a:array[1..1000] of longint;
function hh(x:longint):boolean;
var t:longint;i:word;
begin
t:=1;
for i:=2 to (x div 2) do
if x mod i = 0 then t:=t+i;
if t=x then exit(true);
exit(false);
end;
begin
clrscr;
readln(n);
for i:=1 to n do readln(a[i]);
for i:=1 to n do
if hh(a[i]) = true then writeln(a[i],'la so hoan hao')
else writeln(a[i],'khong phai la so hoan hao');
readln;
end.