program Line;

{$APPTYPE CONSOLE}

uses
  SysUtils;
 var x,i,y,z:integer;
 f:text;
begin
assign(f,'LINE.IN');
reset(f);
read(f,z);
repeat begin
read(f,x);
if x>143 then
writeln('NO')
else begin;
if x mod 2=0 then begin
y:= ((x*5)-5) div 60;
i:= ((x*5)-5) mod 60;
end;
if x mod 2 =1 then begin
y:= (x*5) div 60;
i:= ((x*5) mod 60)-5 ;
end;
writeln(y,' ',i);
 end;
end;
until eof(f);

  { TODO -oUser -cConsole Main : Insert code here }
end.
