var
 k,n,n1,n2,i,q:longint;
begin
 assign(input,'LINE.IN'); reset(input);
 read(q);
  for i:=1 to q do begin
 read(n);
 k:=0; n1:=0; n2:=5;
 while(2+2=4) do begin
  n1:=n1+10;
  k:=k+1;
  if n1>=720 then begin
   writeln('NO'); break;
  end;
  if k=n then begin
   writeln((n1-10) div 60,' ',(n1-10) mod 60); break;
  end;
   n2:=n2+10;
  if n2>=720 then begin
   writeln('NO'); break;
  end;
    k:=k+1;
   if k=n then begin
    writeln((n2-10) div 60,' ',(n2-10) mod 60); break;
    end;
 end; end;
 end.


