
{$APPTYPE CONSOLE}
var n, p, i, z: integer;
begin
  assign(input, 'WEIGHING.IN'); reset(input);
  read(p);
  for i := 1 to p do
  begin
    z:=0;
    read(n);

    while n>=2 do
      begin
        if n=2 then n:= n div 2

        else n:=n div 3 + n mod 3;

        z:=z+1;
      end;
    writeln(z);
  end;

end.
