program LINE;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 f:text;
 i,n,k,c,m,v:integer;
begin
 assign(f,'LINE.IN');
 reset(f);
 readln(f,n);
 for i:=1 to n do begin
  readln(f,k);
  if k > (72+71) then writeln('NO')
  else begin
   v:=((k-1)*10) div 2;
   c:=v div 60;
   m:=v mod 60;
   writeln(c,' ',m);
  end;

 end;
 close(f);
end.
 