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

public class canalisation_akov_n2 {
	FastScanner in;
	PrintWriter out;

	int n, m;
	ArrayList<Integer>[] g;
	int[][] next;
	int curL, curNext;
	
	void dfs(int v, int parent) {
		next[curL][v] = curNext;
		for (int u : g[v]) {
			if (u != parent) {
				dfs(u, v);
			}
		}
	}
	
	public void solve() throws IOException {
		n = in.nextInt();
		m = in.nextInt();
		g = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<Integer>();
		}
		next = new int[n][n];
		for (int i = 0; i < n - 1; i++) {
			int a = in.nextInt() - 1, b = in.nextInt() - 1;
			g[a].add(b);
			g[b].add(a);
		}
		for (curL = 0; curL < n; curL++) {
			for (int j : g[curL]) {
				curNext = j;
				dfs(curNext, curL);
			}
		}
		for (int i = 0; i < m; i++) {
			out.println(next[in.nextInt() - 1][in.nextInt() - 1] + 1);
		}
	}

	public void run() {
		try {
			in = new FastScanner(new File("canalisation.in"));
			out = new PrintWriter(new File("canalisation.out"));

			solve();

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

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

	}

	public static void main(String[] arg) {
		new canalisation_akov_n2().run();
	}
}