program Line;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var n,i,k,y,x,d:integer;
begin
Assign (input,'Line.in');
reset(input);
readln(n);
for i:=1 to n do
begin
readln (k);
d:=((k*10) div 2)-5;
x:=d div 60;
y:=d mod 60;
if d>720 then writeln ('NO') else writeln(x,' ',y);
end;
end.
 