program line;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
 n,a, rez, i: integer;
begin
assign(input,'line.in'); reset (input);
read (n);
for i:=1 to n do begin
  read (a);
  if a > 145 then write('NO')
    else begin
    if (a mod 2) = 0 then
      rez := ((a div 2)-1) * 10 + 5
      else
        rez := (a div 2) * 10;
    write (rez div 60,' ', rez mod 60);
    end;
    writeln;
end;

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