program line;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
x,c,i,d,r,e:integer;
begin
assign (input,'line.in');
reset(input);
read(x);
for i:=1 to x do
read(c);
d:=c*5;
if d > 143
then
write('NO')
else
e:=d div 60;
r:=d mod 60;
writeln('',e,' ',r);
close(input)
end.
