#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll L[100];
ll P[100][20];
ll T[100];
vector<ll>graph[100];
void dfs(ll src,ll par)
{
if(src==-1)
L[par]=1;
else
L[par]=L[src]+1;
T[par]=src;
ll len=graph[par].size();
for(ll i=0; i<(ll)graph[par].size(); i++)
{
ll v=graph[par][i];
if(v!=src)
{
dfs(par,v);
}
}
}
ll query(ll n,ll p,ll q)
{
ll log=1,i,j,temp;
if(L[p]<L[q])
{
temp=q;
q=p;
p=temp;
}
log=log2(n);
for(j=log; j>=0; j--)
{
if(L[p]-(1<<j)>=L[q])
{
p=P[p][j];
}
}
if(p==q)
return p;
for(j=log; j>=0; j--)
{
if(P[p][j]!=-1&&P[p][j]!=P[q][j])
p=P[p][j],q=P[q][j];
}
return T[p];
}
void lca(ll n)
{
memset(P,-1,sizeof(P));
ll i,j;
for(i=1; i<=n; i++)
P[i][0]=T[i];
for(j=1; (1<<j)<n; j++)
{
for(i=1; i<=n; i++)
{
if(P[i][j-1]!=-1)
{
P[i][j]=P[P[i][j-1]][j-1];
}
}
}
}
int main()
{
ll i,j,n,m,t,a,b;
scanf("%lld",&n);
for(i=0; i<n-1; i++)
{
scanf("%lld%lld",&a,&b);
graph[a].push_back(b);
graph[b].push_back(a);
}
dfs(-1,1);
lca(n);
cin>>a>>b;
cout<<query(n,a,b)<<endl;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgbGwgbG9uZyBsb25nCgpsbCBMWzEwMF07CmxsIFBbMTAwXVsyMF07CmxsIFRbMTAwXTsKdmVjdG9yPGxsPmdyYXBoWzEwMF07Cgp2b2lkIGRmcyhsbCBzcmMsbGwgcGFyKQp7CiAgICBpZihzcmM9PS0xKQogICAgICAgIExbcGFyXT0xOwogICAgZWxzZQogICAgICAgIExbcGFyXT1MW3NyY10rMTsKICAgIFRbcGFyXT1zcmM7CiAgICBsbCBsZW49Z3JhcGhbcGFyXS5zaXplKCk7CiAgICBmb3IobGwgaT0wOyBpPChsbClncmFwaFtwYXJdLnNpemUoKTsgaSsrKQogICAgewogICAgICAgIGxsIHY9Z3JhcGhbcGFyXVtpXTsKICAgICAgICBpZih2IT1zcmMpCiAgICAgICAgewogICAgICAgICAgICBkZnMocGFyLHYpOwogICAgICAgIH0KICAgIH0KfQoKbGwgcXVlcnkobGwgbixsbCBwLGxsIHEpCnsKICAgIGxsIGxvZz0xLGksaix0ZW1wOwogICAgaWYoTFtwXTxMW3FdKQogICAgewogICAgICAgIHRlbXA9cTsKICAgICAgICBxPXA7CiAgICAgICAgcD10ZW1wOwogICAgfQoKICAgIGxvZz1sb2cyKG4pOwoKICAgIGZvcihqPWxvZzsgaj49MDsgai0tKQogICAgewogICAgICAgIGlmKExbcF0tKDE8PGopPj1MW3FdKQogICAgICAgIHsKICAgICAgICAgICAgcD1QW3BdW2pdOwogICAgICAgIH0KICAgIH0KCiAgICBpZihwPT1xKQogICAgICAgIHJldHVybiBwOwoKICAgIGZvcihqPWxvZzsgaj49MDsgai0tKQogICAgewogICAgICAgIGlmKFBbcF1bal0hPS0xJiZQW3BdW2pdIT1QW3FdW2pdKQogICAgICAgICAgICBwPVBbcF1bal0scT1QW3FdW2pdOwogICAgfQogICAgcmV0dXJuIFRbcF07Cn0KCgp2b2lkIGxjYShsbCBuKQp7CiAgICBtZW1zZXQoUCwtMSxzaXplb2YoUCkpOwogICAgbGwgaSxqOwogICAgZm9yKGk9MTsgaTw9bjsgaSsrKQogICAgICAgIFBbaV1bMF09VFtpXTsKICAgIGZvcihqPTE7ICgxPDxqKTxuOyBqKyspCiAgICB7CiAgICAgICAgZm9yKGk9MTsgaTw9bjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoUFtpXVtqLTFdIT0tMSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgUFtpXVtqXT1QW1BbaV1bai0xXV1bai0xXTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfQoKaW50IG1haW4oKQp7CiAgICBsbCBpLGosbixtLHQsYSxiOwogICAgc2NhbmYoIiVsbGQiLCZuKTsKICAgIGZvcihpPTA7IGk8bi0xOyBpKyspCiAgICB7CiAgICAgICAgc2NhbmYoIiVsbGQlbGxkIiwmYSwmYik7CiAgICAgICAgZ3JhcGhbYV0ucHVzaF9iYWNrKGIpOwogICAgICAgIGdyYXBoW2JdLnB1c2hfYmFjayhhKTsKICAgIH0KICAgIGRmcygtMSwxKTsKICAgIGxjYShuKTsKCiAgICBjaW4+PmE+PmI7CiAgICBjb3V0PDxxdWVyeShuLGEsYik8PGVuZGw7Cn0KCg==