program line;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 f:text;
 n,i,a,b:integer;
begin
 assignfile(f,'line.in');
 reset(f);
 readln(f,n);
 for i:=1 to n do begin
  readln(f,a);
  b:=(a-1)*5;
  if b>(12*60) then writeln('NO') else begin
  write(b div 60,' ');
  writeln(b-(60*((b div 60))));
  end;
 end;
 closefile(f);
end.
