program Project1;
{$APPTYPE CONSOLE}
uses
  SysUtils;

var
  a: array[1..200] of integer;
  b: array[1..200] of extended;
  x,i,k: integer;
  y1,y2: extended;
  s,ans: string;
  f: textfile;
begin
y1:=0;
y2:=0;
AssignFile(f,'line.in');
reset(f);
readln(f,s);
x:=strtoint(s);
for i:=1 to x do begin
  readln(f,s);
  a[i]:=strtoint(s);
  if a[i]>145 then begin
    ans:='NO';
    writeln(ans);
  end else begin
    b[i]:=5*(a[i]-1);
    while b[i]>=60 do begin
      y1:=y1+1;
      b[i]:=b[i]-60;
    end;
    y2:=b[i];
    ans:=floattostr(y1)+' '+floattostr(y2);
    writeln(ans);
    y1:=0;
  end;
end;
closefile(f);
end.
