{$APPTYPE CONSOLE}
{$MAXSTACKSIZE 64000000}
uses
  SysUtils;
var n, m, i, x, y, k0, t, l, r, j : integer;
  head, next, key, tin, tout, q : array[1..400001] of integer;
  p : array[1..200001] of boolean;

procedure dfs(u : integer);
var
  e : integer;
begin
  inc(t);
  tin[u] := t;
  e := head[u];
  while (e <> -1) do
  begin
    if p[key[e]] then
    begin
      p[key[e]] := false;
      q[key[e]] := u;
      dfs(key[e]);
    end;
    e := next[e];
  end;
  inc(t);
  tout[u] := t;
end;

begin
  assign(input, 'canalisation.in');
  reset(input);
  assign(output, 'canalisation.out');
  rewrite(output);
  readln(n, m);
  for i := 1 to n do
  begin
    head[i] := -1;
    p[i] := true;
  end;
  k0 := 0;
  for i := 1 to (n - 1) do
  begin
    readln(x, y);
    inc(k0);
    key[k0] := y;
    next[k0] := head[x];
    head[x] := k0;
    inc(k0);
    key[k0] := x;
    next[k0] := head[y];
    head[y] := k0;
  end;
  p[1] := false;
  q[1] := -1;
  t := 0;
  dfs(1);
  for i := 1 to m do
  begin
    readln(l, r);
    if not((tin[l] < tin[r]) and (tout[l] > tout[r])) then
      writeln(q[l])
    else
    begin
      j := head[l];
      while (j <> -1) do
      begin
        if (tin[key[j]] <= tin[r]) and (tout[key[j]] >= tout[r]) then
        begin
          writeln(key[j]);
          break;
        end;
        j := next[j];
      end;
    end;
  end;
end.
 
