//https://www.luogu.org/problemnew/show/P3379
#include<bits/stdc++.h>
#define maxn 500010
#define maxm 1000010
using namespace std;
struct edge{
int to,next;
}e[maxm];
int point[maxn],n,m,rt,cnt;
int fa[maxn][20],depth[maxn];
void addedge(int x,int y)
{
e[++cnt].next=point[x];
e[cnt].to=y;
point[x]=cnt;
}
void dfs(int x,int from)
{
depth[x]=depth[from]+1;
fa[x][0]=from;
for(int i=point[x];i;i=e[i].next)
{
int y=e[i].to;
if(y==from)
continue;
dfs(y,x);
}
}
int go_up(int x,int d)
{
for(int j=19;j>=0;j--)
if((1<<j)&d)
x=fa[x][j];
return x;
}
int main()
{
scanf("%d%d%d",&n,&m,&rt);
for(int i=1;i<=n-1;i++)
{
int x,y;
scanf("%d%d",&x,&y);
addedge(x,y);
addedge(y,x);
}
dfs(rt,rt);
for(int j=1;j<=19;j++)
for(int i=1;i<=n;i++)
fa[i][j]=fa[fa[i][j-1]][j-1];
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d%d",&x,&y);
if(depth[x]>depth[y])
x=go_up(x,depth[x]-depth[y]);
if(depth[y]>depth[x])
y=go_up(y,depth[y]-depth[x]);
for(int j=19;j>=0;j--)
if(fa[x][j]!=fa[y][j])
x=fa[x][j],y=fa[y][j];
if(x!=y)
x=fa[x][0];
printf("%d\n",x);
}
return 0;
}