uses
  SysUtils;
var
n,k,y,x,t,i:integer;
begin
assign(input,'line.in'); reset(input);
read(n);
for i:=1 to n do
  begin
    read(k);
    if k>144 then writeln('NO') else
      begin
        t:=(k-1)*5;
        x:=t div 60;
        y:=t mod 60;
        writeln(x,' ',y);
      end;
    end;
end.
