// Arup Guha
// 12/27/2024
// Solution to 2024 SER D1 Problem E: Elevated Rails

import java.util.*;
import java.io.*;

public class elevatedrails {

	public static int n;
	public static ArrayList<Integer>[] g;
	
	// Store component number here.
	public static int[] compNum;
	
	// Store diameter of each component here.
	public static int[] diam;
	
	public static void main(String[] args) throws Exception {
		
		// Get basic input, set up empty graph.
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer tok = new StringTokenizer(stdin.readLine());
		n = Integer.parseInt(tok.nextToken());
		g = new ArrayList[n];
		for (int i=0; i<n; i++)
			g[i] = new ArrayList<Integer>();
		
		// Get number of queries.
		int numQ = Integer.parseInt(tok.nextToken());
		
		// Read and add edges.
		for (int i=0; i<n-3; i++) {
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken())-1;
			int v = Integer.parseInt(tok.nextToken())-1;
			g[u].add(v);
			g[v].add(u);
		}
		
		// Will store max distances here.
		int[] maxD = new int[n];
		Arrays.fill(maxD, -1);
		
		// For identifying components.
		compNum = new int[n];
		Arrays.fill(compNum, -1);
		int id = 0;
		
		// For storing the three diameters.
		diam = new int[3];
		
		// We'll find our three components here.
		for (int i=0; i<n; i++) {
			
			// This component was already done.
			if (maxD[i] != -1) continue;
			
			// Update our distances for this component.
			// Note: Guaranteed this code runs exactly 3 times.
			updateDist(i, maxD, id++);
		}
		
		// Process queries.
		StringBuffer sb = new StringBuffer();
		for (int i=0; i<numQ; i++) {
			
			// Get query and answer --> just sum of max distances to end points plus bridge.
			tok = new StringTokenizer(stdin.readLine());
			int u = Integer.parseInt(tok.nextToken())-1;
			int v = Integer.parseInt(tok.nextToken())-1;
			
			// This is a bit strange, but we're adding the number of vertices visited.
			// Which is the sum of distances on each island plus 3, since the number of
			// vertices visited is 1 more than the distance. maxD[u]+1 is for island u.
			// maxD[v]+1 is for island v. That's what's added here.
			int res = maxD[u]+maxD[v]+2;
			
			// Component numbers sum to 3, so we can get the third component this way.
			int otherC = 3 - compNum[u] - compNum[v];
			
			// We have to travel all the way across this third island. The number of
			// vertices visited is its diameter plus 1.
			res += (diam[otherC]+1);
			
			sb.append(res+"\n");
		}
		
		// Ta da!
		System.out.print(sb);
	}
	
	// Runs BFS from u and gets distance array to all other locations from u.
	// -1 indicates not reached.
	public static int[] getDist(int u) {
	
		// Set up BFS.
		int[] d = new int[n];
		Arrays.fill(d, -1);
		d[u] = 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.offer(u);
		
		// Run BFS.
		while (q.size() > 0) {
		
			// Get next.
			int cur = q.poll();
			
			// Go to neighbors.
			for (Integer next: g[cur]) {
				
				// Been there.
				if (d[next] != -1) continue;
				
				// Update distance, add next to queue.
				d[next] = d[cur]+1;
				q.offer(next);
			}
		}
		
		// Distances we need to return.
		return d;
	}
	
	// Updates max distances from all nodes in component with u to any other node in
	// the same component.
	public static void updateDist(int u, int[] maxD, int id) {
	
		int[] origD = getDist(u);
		
		// Add in IDs.
		for (int i=0; i<n; i++)
			if (origD[i] != -1)
				compNum[i] = id;
		
		// Get furthest valid node from u in this component.
		int end = u;
		for (int i=0; i<n; i++)
			if (origD[i] > origD[end])
				end = i;
				
		// Run second BFS from this "endpoint."
		int[] fromLeft = getDist(end);
		
		// Get the "opposite" end.
		int otherEnd = end;
		for (int i=0; i<n; i++)
			if (fromLeft[i] > fromLeft[otherEnd])
				otherEnd = i;
			
		// This is the diameter of this component.
		diam[id] = fromLeft[otherEnd];
				
		// These are the other distances we need.
		int[] fromRight = getDist(otherEnd);
		
		// Here's the key update we need, which gives us the max distance from us to
		// any other node in our tree.
		for (int i=0; i<n; i++) {
			if (fromLeft[i] == -1) continue;
			maxD[i] = Math.max(fromLeft[i], fromRight[i]);
		}
	}
}