program LINE;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var n,k,a:byte;
begin
  assign(input,'LINE.IN');
  read(n);
  for a:=1 to n do
  begin
  read(k);
  if k>144 then writeln('NO') else
  begin
  writeln(((k*5)-5) div 60,' ', ((k*5)-5) mod 60);
  end;
  end;
    { TODO -oUser -cConsole Main : Insert code here }
end.
