import java.io.*;
import java.util.*;

public class canalisation_pk_slow {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	public String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public void solve() throws IOException {
		int n = nextInt();
		ArrayList<Integer>[] e = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			e[i] = new ArrayList<Integer>();
		}
		int m = nextInt();
		for (int i = 0; i < n - 1; i++) {
			int x = nextInt() - 1;
			int y = nextInt() - 1;
			e[x].add(y);
			e[y].add(x);
		}

		for (int i = 0; i < m; i++) {
			int x = nextInt() - 1;
			int y = nextInt() - 1;
			HashSet<Integer> was = new HashSet<Integer>();
			out.println(dfs(x, y, e, was) + 1);
		}
	}

	private int dfs(int x, int y, ArrayList<Integer>[] e, HashSet<Integer> was) {
		if (was.contains(x))
			return -1;
		was.add(x);
		for (int i = 0; i < e[x].size(); i++) {
			int d = e[x].get(i);
			if (d == y || dfs(d, y, e, was) != -1)
				return d;
		}
		return -1;
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("canalisation.in"));
			out = new PrintWriter("canalisation.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new canalisation_pk_slow().run();
	}
}