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

public class canalisation_av {

	FastScanner in;
	PrintWriter out;
	final String fileName = "canalisation".toLowerCase();

	List<Edge>[] graph;
	int[] timeIn, timeOut;
	Edge[] parentEdge;
	
	int dfs(int u, int time, int parent) {
		timeIn[u] = time++;
		
		for (Edge e : graph[u]) {
			if (e.to == parent) {
				parentEdge[u] = e;
				continue;
			}
			time = dfs(e.to, time, u);
		}
		
		graph[u].remove(parentEdge[u]);
		
		timeOut[u] = time++;
		return time;
	}
	
	void solve() {
		int n = in.nextInt(), m = in.nextInt();
		graph = new List[n];
		timeIn = new int[n]; timeOut = new int[n];
		parentEdge = new Edge[n];
		for (int i = 0; i < n; i++) {
			graph[i] = new ArrayList<>();
		}
		for (int i = 0; i < n - 1; i++) {
			int from = in.nextInt() - 1, to = in.nextInt() - 1;
			graph[from].add(new Edge(from, to, i));
			graph[to].add(new Edge(to, from, i));
		}
		dfs(0, 0, -1);
		
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1, b = in.nextInt() - 1;
			if (!isDescendant(a, b)) {
				out.println(parentEdge[a].to + 1);
			} else {
				int l = -1, r = graph[a].size();
				while (l < r - 1) {
					int mid = (l + r) / 2;
					int tIn = timeIn[graph[a].get(mid).to];
					if (tIn <= timeIn[b]) {
						l = mid;
					} else {
						r = mid;
					}
				}
				out.println(graph[a].get(l).to + 1);
			}
		}
	}
	
	boolean isDescendant(int first, int second) {
		return timeIn[first] < timeIn[second] && timeOut[second] < timeOut[first];
	}
	
	class Edge {
		int from, to, id;

		public Edge(int from, int to, int id) {
			super();
			this.from = from;
			this.to = to;
			this.id = id;
		}
		
	}

	void run() {
		try {
			in = new FastScanner(fileName + ".in");
			out = new PrintWriter(fileName + ".out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					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[] args) {
		new canalisation_av().run();
	}
}
