program line;

{$APPTYPE CONSOLE}

uses
  SysUtils, System;
var
  fin: TextFile;
  l: string;
  tests,n,i,m,h: integer;

begin
  { TODO -oUser -cConsole Main : Insert code here }
  AssignFile(fin,'line.in');
  Reset(fin);
  ReadLn(fin,l);
  tests:=StrToInt(l);
  for i:=1 to tests do begin
    ReadLn(fin,l);
    n:=StrToInt(l);
    m:=(n-1)*5;
    if m>720 then WriteLn('NO') else begin
      h:=m div 60;
      m:=m mod 60;
      WriteLn(IntToStr(h)+' '+IntToStr(m));
    end;
  end;
  CloseFile(fin);
end.
