program Project3;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var n,k,i,x,y,t,h:integer;
begin
assign(input,'line.in');
reset(input);
read(n);
for i:=1 to n do
begin
read(k);
if (k mod 2)=0 then
             begin
       h:=k div 2;
       t:=h*10-5;
       x:=t div 60;
       y :=t mod 60;
       if t>715 then writeln ('NO');
       if t<=715 then writeln (x,' ',y);
       end;
if (k mod 2)<>0 then begin
       h:=k div 2;
       t:=h*10;
       x:=t div 60;
       y :=t mod 60;
       if t>=730 then writeln ('NO') else
       writeln (x,' ',y);
       end;
end;
end.
 