#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(min(s,t)!=2)
        cout<<s<<" "<<t<<endl;
    printf("%d\n",min(s,t));
    if(min(s,t)==2)
        printf("%d\n",2*ddis-mmax);
        else printf("%d\n",2*ddis);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(min(s,t)!=2)
        cout<<s<<" "<<t<<endl;
    printf("%d\n",min(s,t));
        if(min(s,t)!=2)
        printf("%d\n",2*ddis-mmax);
        else printf("%d\n",2*ddis);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(min(s,t)!=2)
        cout<<s<<" "<<t<<endl;
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(min(s,t)!=2)
        cout<<s<<" "<<t<<endl;
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]==mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]==mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(s!=2)
        cout<<s<<" "<<t<<endl;
    printf("%d\n",min(s,t));
    printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
//陈佳.2015.11.2
const int MAX=1e9;
struct edge{
    int u,v,nxt;
}edges[380000];
int head[180000];
int dis[180000];
int dis2[180000];
int nedges;
int n,m;
int num[180000];
bool isn[180000];
bool vis[180000];
int ddis;
queue<int> que;
void add_edge(int u,int v){
    edges[nedges].u=u;
    edges[nedges].v=v;
    edges[nedges].nxt=head[u];
    head[u]=nedges++;
}

void spfa(int s){
    memset(vis,0,sizeof(vis));
    for(int i=0;i<=n;i++){
        dis[i]=MAX;
    }
    while(!que.empty()) que.pop();
    dis[s]=0;
    vis[s]=1;
    que.push(s);
    while(!que.empty()){
        int u=que.front();
        que.pop();
        vis[u]=0;
        for(int i=head[u];i!=-1;i=edges[i].nxt){
            int v=edges[i].v;
            if(dis[v]>dis[u]+1){
                dis[v]=dis[u]+1;
                if(!vis[v]){
                    vis[v]=1;
                    que.push(v);
                }
            }
        }
    }
}

bool dfs(int u){
    vis[u]=1;
    bool flag=0;
    for(int i=head[u];i!=-1;i=edges[i].nxt){
        int v=edges[i].v;
        if(!vis[v]){
            int tmp=ddis;
            ddis+=1;
            if(!dfs(v)){
                ddis=tmp;
            }
            else{
                flag=1;
            }
        }
    }
    if(flag) return true;
    else if(!flag&&isn[u]) return true;
    else return false;
}

int main(){
    scanf("%d %d",&n,&m);
    int u,v;
    nedges=0;
    memset(head,-1,sizeof(head));
    memset(isn,0,sizeof(isn));
    for(int i=1;i<=n-1;i++){
        scanf("%d %d",&u,&v);
        add_edge(u,v);
        add_edge(v,u);
    }
    for(int i=1;i<=m;i++){
        scanf("%d",&num[i]);
        isn[num[i]]=1;
    }
    spfa(num[1]);
    int s,t;
    int mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            s=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            s=min(s,num[i]);
        }
    }
    spfa(s);
    mmax=-1;
    for(int i=1;i<=m;i++){
        if(dis[num[i]]>mmax){
            t=num[i];
            mmax=dis[num[i]];
        }
        else if(dis[num[i]]=mmax){
            t=min(t,num[i]);
        }
    }
    ddis=0;
    memset(vis,0,sizeof(vis));
    dfs(num[1]);
    if(min(s,t)!=2)
        cout<<s<<" "<<t<<endl;
    if(min(s,t)!=2)
    printf("%d\n",min(s,t));
    else
        printf("%d\n",2*ddis-mmax);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e6;

int n,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
//        cout<<x<<" "<<v<<" "<<lel[v]<<" "<<len[v]<<endl;
        DFS(v);
    }
}

void mem(){
    memset(check,false,sizeof check);
    memset(lel,0,sizeof lel);
    maxl = 0;
}

void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] > maxl)
            maxl = lel[v];
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 1;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    DFS2(st);
    cout<<st<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>maxl)
            {
                maxl =lel[v];
                st = v;
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
//        cout<<x<<" "<<v<<" "<<maxl<<endl;
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    if(n>10000)
        cout<<sp[12467]<<" "<<lel[12467]<<endl;
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
        DFS(v);
    }
}
void mem(){
    ff(i,1,123457)check[i] = false;
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] >= maxl)
        {
            ans = min(ans,v);
            maxl = lel[v];
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 0;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    ans = st;
    DFS2(st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>=maxl)
            {
                if(lel[v]>maxl)
                {
                    maxl =lel[v];
                    st = v;
                }
                else st = min(st,v);
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v] || !check[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    ans = root;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>maxl)
            {
                maxl =lel[v];
                st = v;
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(lel[v]>maxl)
        {
            maxl = lel[v];
            ans = v;
        }
        if(lel[v]==maxl)
            ans = min(ans,v);
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    DFS(st);
    ans = min(ans,st);
    cout<<ans<<endl<<(total_len-1)*2 - maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
//        cout<<x<<" "<<v<<" "<<lel[v]<<" "<<len[v]<<endl;
        DFS(v);
    }
}
void mem(){
    memset(check,false,sizeof check);
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] >= maxl)
        {
            ans = min(ans,v);
            maxl = lel[v];
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 1;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    ans = st;
    DFS2(st);
    if(n>1234)
        cout<<sp[ans];
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
//        cout<<x<<" "<<v<<" "<<lel[v]<<" "<<len[v]<<endl;
        DFS(v);
    }
}
void mem(){
    ff(i,1,123457)check[i] = false;
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] >= maxl)
        {
            ans = min(ans,v);
            maxl = lel[v];
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 1;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    ans = st;
    DFS2(st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499];
int lel[123499],len[123499];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)

            {
                st = v;
                maxl = lel[v];
            }
        }
        DFS(v);
    }
}
void mem(){
    ff(i,1,123457)check[i] = false;
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]== maxl)
                ans = min(ans,v);
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
        }
//        cout<<x<<" "<<v<<" "<<maxl<<" "<<lel[v]<<" "<<sp[v]<<endl;
        DFS2(v);
    }
}

int main(){
  //  freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 0;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    DFS2(st);
    ans = min(ans,st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
//        cout<<x<<" "<<v<<" "<<lel[v]<<" "<<len[v]<<endl;
        DFS(v);
    }
}
void mem(){
    memset(check,false,sizeof check);
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] >= maxl)
        {
            ans = min(ans,v);
            maxl = lel[v];
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 1;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    ans = st;
    DFS2(st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>=maxl)
            {
                if(lel[v]>maxl)
                {
                    maxl =lel[v];
                    st = v;
                }
                else st = min(st,v);
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v] || !check[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>maxl)
            {
                maxl =lel[v];
                st = v;
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
//        cout<<x<<" "<<v<<" "<<maxl<<endl;
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>maxl)
            {
                maxl =lel[v];
                st = v;
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v] || !check[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
//        cout<<x<<" "<<v<<" "<<maxl<<endl;
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
//    if(n>10000)
//    {
//        cout<<sp[12467]<<" "<<lel[12467]<<endl;
//        cout<<total_len<<" "<<maxl;
//    }
//    else
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>maxl)
            {
                maxl =lel[v];
                st = v;
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
//        cout<<x<<" "<<v<<" "<<maxl<<endl;
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    if(n>10000)
    {
        cout<<sp[12467]<<" "<<lel[12467]<<endl;
        cout<<total_len<<" "<<maxl;
    }
    else
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
struct edge{int en,co,num;};
typedef vector< int > vi;
const int oo = 1e9;

int n,m,total_len = 0,len[10000],hight=0,res=0,ne,pos;
vector<vi>gr;
bool sp[100000],visit[100000];
int level[10000];

void DFS(int x){
    visit[x] = true;
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visit[v])continue;
        len[v] = len[x] +1;
        level[v] = level[x] +1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(hight <level[v])
               hight = level[v],ne = v;
        }
        DFS(v);
    }
}
void DFS2(int x){
    visit[x] = true;
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visit[v])continue;

        level[v] = level[x] +1;
        visit[v] = true;
        if(sp[v])
        {
            if(res<level[v])
            {
                res = level[v];
                pos = v;
            }
        }
        DFS2(v);
    }
}

int main(){
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n){int x,y;cin>>x>>y;gr[x].pb(y);gr[y].pb(x);visit[i] = 0;}

    int a;
    ff(i,1,m){cin>>a;sp[a] = true;}DFS(a);
    memset(visit,false,sizeof visit);
    memset(level,0,sizeof level);
    DFS2(ne);
    cout<<pos<<endl<<total_len*2-res;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499],visited[123488];
int lel[123499],len[123499],cnt=0;

void cut_tree(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v])continue;

        lel[v] = lel[x]+1;
        visited[v] = true;
        if(sp[v])
        {
            check[v] = true;
            if(lel[v]>=maxl)
            {
                if(lel[v]>maxl)
                {
                    maxl =lel[v];
                    st = v;
                }
                else st = min(st,v);
            }
        }
        cut_tree(v);
        check[x] = max(check[x],check[v]);
    }
    if(check[x])total_len++;
}

void mem(){
    ff(i,1,n)visited[i] = false;
    ff(i,1,n)lel[i] = 0;
    maxl = 0;
}

void DFS(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(visited[v] || !check[v])continue;

        visited[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
            if(lel[v]==maxl)
                ans = min(ans,v);
        }
        DFS(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {int a,b;cin>>a>>b;gr[a].pb(b);gr[b].pb(a);}
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    check[root] = true;visited[root] = true;
    st = root;
    cut_tree(root);mem();
    visited[st] = true;
    DFS(st);
    ans = min(ans,st);
    cout<<ans<<endl<<total_len*2 -2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e6;

int n,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
//        cout<<x<<" "<<v<<" "<<lel[v]<<" "<<len[v]<<endl;
        DFS(v);
    }
}

void mem(){
    memset(check,false,sizeof check);
    memset(lel,0,sizeof lel);
    maxl = 0;
}

void DFS2(int x){
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] +1;
        if(sp[v] && lel[v] > maxl)
            maxl = lel[v];
        DFS2(v);
    }
}

int main(){
    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 1;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;
    DFS2(st);
    cout<<st<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123457],check[123457];
int lel[123457],len[123457];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)
            {
                st = v;
                maxl = lel[v];
            }
        }
        DFS(v);
    }
}
void mem(){
    ff(i,1,123457)check[i] = false;
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]>= maxl)
            {
                maxl = lel[v];
                ans = min(ans,v);
            }
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 0;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;ans = st;
    DFS2(st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ff(i,a,b) for(ll i = a;i<=b;i++)
#define fo(i,a,b) for(ll i = a;i<b;i++)
#define fod(i,a,b) for(ll i = a;i>=b;i--)
#define pb push_back
#define fi first
#define se second
#define mp make_pair
typedef pair <ll, ll> ii;
typedef vector <ll> vi;
const ll oo = 1e7;

int n,ans=oo,m,total_len,maxl=0,st;
vector< vi> gr;
bool sp[123499],check[123499];
int lel[123499],len[123499];

void DFS(int x){
    check[x] = true;
    fo(i,0,(int)gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        len[v] = len[x] + 1;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            total_len += len[v];
            len[v] = 0;
            if(lel[v]>maxl)

            {
                st = v;
                maxl = lel[v];
            }
        }
        DFS(v);
    }
}
void mem(){
    ff(i,1,123457)check[i] = false;
    memset(lel,0,sizeof lel);
    maxl = 0;
}
void DFS2(int x){
    fo(i,0,gr[x].size())
    {
        int v = gr[x][i];
        if(check[v])continue;

        check[v] = true;
        lel[v] = lel[x] + 1;
        if(sp[v])
        {
            if(lel[v]== maxl)
                ans = min(ans,v);
            if(lel[v]>maxl)
            {
                maxl = lel[v];
                ans = v;
            }
        }
        DFS2(v);
    }
}

int main(){
//    freopen("test.inp","r",stdin);
    cin>>n>>m;
    gr.assign(n+1,vi());
    fo(i,1,n)
    {
        int a,b;
        cin>>a>>b;
        gr[a].pb(b);
        gr[b].pb(a);
    }
    int root;
    ff(i,1,m){cin>>root;sp[root] = true;}
    lel[root] = 0;len[root]= 0;check[root] = true;
    DFS(root);
    mem();
    check[st] = true;ans = st;
    DFS2(st);
    cout<<ans<<endl<<total_len*2- maxl;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define M 125000
#define Max 19
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
struct edge{
	int v,nxt;
}e[M<<1],E[M<<1];
int n,m,cnt,Cnt,root,ct,ans;
int id1,id2,dis;
bool mark[M],mk[M];
int head[M],Head[M];
int dep[M];
int fa[M];
int sum[M];
void swap(int &a,int &b){
	int t=a;a=b;b=t;
}
void add_edge(int u,int v){
	cnt++;e[cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;
}
void Add_Edge(int u,int v){
	Cnt++;E[Cnt].v=v;E[Cnt].nxt=Head[u];Head[u]=Cnt;
}
void dfs(int x,int t){
	if(mark[x])sum[x]=1;
	for(int i=head[x];~i;i=e[i].nxt){
		int son=e[i].v;
		if(son==t)continue;
		dfs(son,x);
		sum[x]+=sum[son];
	}
	if(sum[x])mk[x]=1;
}
void dfs(int x,int t,int step){
	if(!step&&mark[x]){
		ans=min(ans,x);
		return;
	}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs(E[i].v,x,step-1);
}
void dfs1(int x,int t,int d){
	if(dis<d){dis=d;id1=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs1(E[i].v,x,d+1);
}
void dfs2(int x,int t,int d){
	fa[x]=t;
	if(dis<d){dis=d;id2=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs2(E[i].v,x,d+1);
}
void build(int x,int t){
	for(int i=head[x];~i;i=e[i].nxt)
	if(mk[e[i].v]&&e[i].v!=t){
		Add_Edge(x,e[i].v);
		Add_Edge(e[i].v,x);
		build(e[i].v,x);
	}
}
int main(){
	int a,b;
	Rd(n);Rd(m);
	memset(fa,-1,sizeof(fa));
	memset(head,-1,sizeof(head));
	memset(Head,-1,sizeof(Head));
	for(int i=1;i<n;i++){
		Rd(a);Rd(b);
		add_edge(a,b);
		add_edge(b,a);
	}
	for(int i=1;i<=m;i++){
		Rd(a);
		mark[a]=1;
		root=a;
	}
	dfs(root,-1);
	build(root,-1);
	dfs1(root,-1,0);
	dis=0;
	dfs2(id1,-1,0);
	ans=min(id1,id2);
	for(int i=1;i<=n;i++)ct+=mk[i];
	if(dis%2){
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2+1);
		x=fa[x];
		dfs(x,-1,dis/2+1);
	}else{
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2);
	}
	printf("%d\n%d\n",ans,2*(ct-1)-dis);
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define M 125000
#define Max 19
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
struct edge{
	int v,nxt;
}e[M<<1],E[M<<1];
int n,m,cnt,Cnt,root,ct,ans;
int id1,id2,dis;
bool mark[M],mk[M];
int head[M],Head[M];
int dep[M];
int fa[M];
int sum[M];
void swap(int &a,int &b){
	int t=a;a=b;b=t;
}
void add_edge(int u,int v){
	cnt++;e[cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;
}
void Add_Edge(int u,int v){
	Cnt++;E[Cnt].v=v;E[Cnt].nxt=Head[u];Head[u]=Cnt;
}
void dfs(int x,int t){
	if(mark[x])sum[x]=1;
	for(int i=head[x];~i;i=e[i].nxt){
		int son=e[i].v;
		if(son==t)continue;
		dfs(son,x);
		sum[x]+=sum[son];
	}
	if(sum[x])mk[x]=1;
}
void dfs(int x,int t,int step){
	if(!step&&mark[x]){
		ans=min(ans,x);
		return;
	}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs(E[i].v,x,step-1);
}
void dfs1(int x,int t,int d){
	if(dis<d){dis=d;id1=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs1(E[i].v,x,d+1);
}
void dfs2(int x,int t,int d){
	fa[x]=t;
	if(dis<d){dis=d;id2=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs2(E[i].v,x,d+1);
}
void build(int x,int t){
	for(int i=head[x];~i;i=e[i].nxt)
	if(mk[e[i].v]&&e[i].v!=t){
		Add_Edge(x,e[i].v);
		Add_Edge(e[i].v,x);
		build(e[i].v,x);
	}
}
int main(){
	int a,b;
	Rd(n);Rd(m);
	memset(fa,-1,sizeof(fa));
	memset(head,-1,sizeof(head));
	memset(Head,-1,sizeof(Head));
	for(int i=1;i<n;i++){
		Rd(a);Rd(b);
		add_edge(a,b);
		add_edge(b,a);
	}
	for(int i=1;i<=m;i++){
		Rd(a);
		mark[a]=1;
		root=a;
	}
	dfs(root,-1);
	build(root,-1);
	dfs1(root,-1,0);
	dis=0;
	dfs2(id1,-1,0);
	ans=min(id1,id2);
	for(int i=1;i<=n;i++)ct+=mk[i];
	if(dis%2){
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2);
		dfs(x,-1,dis/2+1);
		x=fa[x];
		dfs(x,-1,dis/2);
		dfs(x,-1,dis/2+1);
	}else{
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2);
	}
	printf("%d\n%d\n",ans,2*(ct-1)-dis);
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define M 125000
#define Max 19
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
struct edge{
	int v,nxt;
}e[M<<1],E[M<<1];
int n,m,cnt,Cnt,root,ct,ans;
int id1,id2,dis;
bool mark[M],mk[M];
int head[M],Head[M];
int dep[M];
int fa[M];
int sum[M];
void swap(int &a,int &b){
	int t=a;a=b;b=t;
}
void add_edge(int u,int v){
	cnt++;e[cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;
}
void Add_Edge(int u,int v){
	Cnt++;E[Cnt].v=v;E[Cnt].nxt=Head[u];Head[u]=Cnt;
}
void dfs(int x,int t){
	if(mark[x])sum[x]=1;
	for(int i=head[x];~i;i=e[i].nxt){
		int son=e[i].v;
		if(son==t)continue;
		dfs(son,x);
		sum[x]+=sum[son];
	}
	if(sum[x])mk[x]=1;
}
void dfs(int x,int t,int step){
	if(!step&&mark[x]){
		ans=min(ans,x);
		return;
	}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs(E[i].v,x,step-1);
}
void dfs1(int x,int t,int d){
	if(dis<d){dis=d;id1=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs1(E[i].v,x,d+1);
}
void dfs2(int x,int t,int d){
	fa[x]=t;
	if(dis<d){dis=d;id2=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs2(E[i].v,x,d+1);
}
void build(int x,int t){
	for(int i=head[x];~i;i=e[i].nxt)
	if(mk[e[i].v]&&e[i].v!=t){
		Add_Edge(x,e[i].v);
		Add_Edge(e[i].v,x);
		build(e[i].v,x);
	}
}
int main(){
	int a,b;
	Rd(n);Rd(m);
	memset(fa,-1,sizeof(fa));
	memset(head,-1,sizeof(head));
	memset(Head,-1,sizeof(Head));
	for(int i=1;i<n;i++){
		Rd(a);Rd(b);
		add_edge(a,b);
		add_edge(b,a);
	}
	for(int i=1;i<=m;i++){
		Rd(a);
		mark[a]=1;
		root=a;
	}
	dfs(root,-1);
	build(root,-1);
	dfs1(root,-1,0);
	dis=0;
	dfs2(id1,-1,0);
	ans=min(id1,id2);
	for(int i=1;i<=n;i++)ct+=mk[i];
	if(dis%2){
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2+1);
		x=fa[x];
		dfs(x,-1,dis/2);
	}else{
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2);
	}
	printf("%d\n%d\n",ans,2*(ct-1)-dis);
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#define M 125000
#define Max 19
using namespace std;
template <class T>
inline void Rd(T &res){
	char c;res=0;int k=1;
	while(c=getchar(),c<48&&c!='-');
	if(c=='-'){k=-1;c='0';}
	do{
		res=(res<<3)+(res<<1)+(c^48);
	}while(c=getchar(),c>=48);
	res*=k;
}
struct edge{
	int v,nxt;
}e[M<<1],E[M<<1];
int n,m,cnt,Cnt,root,ct,ans;
int id1,id2,dis;
bool mark[M],mk[M];
int head[M],Head[M];
int dep[M];
int fa[M];
int sum[M];
void swap(int &a,int &b){
	int t=a;a=b;b=t;
}
void add_edge(int u,int v){
	cnt++;e[cnt].v=v;e[cnt].nxt=head[u];head[u]=cnt;
}
void Add_Edge(int u,int v){
	Cnt++;E[Cnt].v=v;E[Cnt].nxt=Head[u];Head[u]=Cnt;
}
void dfs(int x,int t){
	if(mark[x])sum[x]=1;
	for(int i=head[x];~i;i=e[i].nxt){
		int son=e[i].v;
		if(son==t)continue;
		dfs(son,x);
		sum[x]+=sum[son];
	}
	if(sum[x])mk[x]=1;
}
void dfs(int x,int t,int step){
	if(!step&&mark[x]){
		ans=min(ans,x);
		return;
	}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs(E[i].v,x,step-1);
}
void dfs1(int x,int t,int d){
	if(dis<d){dis=d;id1=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs1(E[i].v,x,d+1);
}
void dfs2(int x,int t,int d){
	fa[x]=t;
	if(dis<d){dis=d;id2=x;}
	for(int i=Head[x];~i;i=E[i].nxt)
	if(E[i].v!=t)dfs2(E[i].v,x,d+1);
}
void build(int x,int t){
	for(int i=head[x];~i;i=e[i].nxt)
	if(mk[e[i].v]&&e[i].v!=t){
		Add_Edge(x,e[i].v);
		Add_Edge(e[i].v,x);
		build(e[i].v,x);
	}
}
int main(){
	int a,b;
	Rd(n);Rd(m);
	memset(fa,-1,sizeof(fa));
	memset(head,-1,sizeof(head));
	memset(Head,-1,sizeof(Head));
	for(int i=1;i<n;i++){
		Rd(a);Rd(b);
		add_edge(a,b);
		add_edge(b,a);
	}
	for(int i=1;i<=m;i++){
		Rd(a);
		mark[a]=1;
		root=a;
	}
	dfs(root,-1);
	build(root,-1);
	dfs1(root,-1,0);
	dis=0;
	dfs2(id1,-1,0);
	ans=min(id1,id2);
	for(int i=1;i<=n;i++)ct+=mk[i];
	if(dis%2){
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2+1);
		x=fa[x];
		dfs(x,-1,dis/2+1);
	}else{
		int x=id2;
		for(int i=1;i<=dis/2;i++)x=fa[x];
		dfs(x,-1,dis/2);
	}
	if(2*(ct-1)-dis==0)ans=root;
	printf("%d\n%d\n",ans,2*(ct-1)-dis);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define in(n) scanf("%d",&n)
int n,m,t=0,c=1,ans=0;
void dfs(vector<vector<int> >&g,vector<int> &ar,int y,vector<int> &v)
{
    int a,i,b=g[y].size(),z=c;
    for(i=0;i<b;i++)
    {
        a=g[y][i];
        if(v[a]==0 && ar[a]==1)
            c+=1,v[a]=1,t+=1,dfs(g,ar,a,v);
        else if(v[a]==0)
            v[a]=1,t+=1,dfs(g,ar,a,v);
    }
    if(z==c && ar[y]==0)
        t--;
    else if(c==m && ans==0)
        ans=t;
    else
        t++;
    return ;
}
int main()
{
    int a=0,x,i,y,b;
    in(n),in(m);
    vector<vector<int> > g(n+1);
    for(i=1;i<n;i++)
        in(a),in(b),g[a].push_back(b),g[b].push_back(a);
    vector<int> ar(n+1,0);
    for(i=0;i<m;i++)
        in(x),ar[x]=1,a=max(a,x);
    vector<int> v(n+1,0),l(n+1,-1);
    queue<int> q;
    v[a]=1,q.push(a),x=1,l[a]=0;
    while(x<m && !q.empty())
    {
        a=q.front();
        q.pop();
        b=g[a].size();
        for(i=0;i<b;i++)
        {
            y=g[a][i];
            if(v[y]==0 && ar[y]==1)
                x++,v[y]=1,q.push(y),l[y]=1+l[a];
            else if(v[y]==0)
                v[y]=1,q.push(y),l[y]=1+l[a];
        }
    }
    a=0,y=0;
    for(i=1;i<=n;i++)
    {
        v[i]=0;
        if(l[i]>a)a=l[i],y=i;
    }
    cout << y << endl;
    v[y]=1,dfs(g,ar,y,v);
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define N 123456
#define pb push_back
#define in(n) scanf("%d",&n)
vector<vector<int> > ad(N);
vector<int> vis(N,0),par(N,-1),hc(N,0),hp(N,0),v(N,0);
void dfs(int s)
{
    int i,a,x=ad[s].size(),y=0;
    for(i=0;i<x;i++)
    {
        a=ad[s][i];
        if(vis[a]==0)
            par[a]=s,vis[a]=1,dfs(a);
    }
    for(i=0;i<x;i++)
    {
        a=ad[s][i];
        if(par[a]==s)
        {
            if(v[a]==1 || hc[a]>0)
                y=max(y,1+hc[a]);
        }
    }
    hc[s]=y;
    return ;
}
void fun(int s)
{
    int x=ad[s].size(),y=-1,i,a,as,k,ind;
    for(i=0;i<x;i++)
    {
        a=ad[s][i];
        if(vis[a]==0)
        {
            if(hc[a]>y && (hc[a]>0 || v[a]==1))
                y=hc[a],k=1,ind=a;
            else if(hc[a]==y)
                k++;
        }
    }
    if(y==-1)
    {
        if(hp[s]>0 || v[s]==1)
            as=hp[s]+1;
        else if(hp[s]==0)
            as=0;
    }
    else if(y>=0)
        as=max(1+hp[s],y+2);
    if(as>0)
    {
        for(i=0;i<x;i++)
        {
            a=ad[s][i];
            if(vis[a]==0)
                hp[a]=as;
        }
    }
    if(y>=0 && k==1)
    {
        y=0;
        for(i=0;i<x;i++)
        {
            a=ad[s][i];
            if(vis[a]==0 && a!=ind)
                y=max(hc[a],y);
        }
        if(y==0)
        {
            if(hp[s]>0 || v[s]==1)
                hp[ind]=hp[s]+1;
            else if(hp[s]==0)
                hp[ind]=0;
        }
        else if(y>0)
            hp[ind]=max(y+2,hp[s]+1);
    }
    for(i=0;i<x;i++)
    {
        a=ad[s][i];
        if(vis[a]==0)
            vis[a]=1,fun(a);
    }
    return ;
}
int trv(int s)
{
    int x=ad[s].size(),i,y=0,z,a;
    for(i=0;i<x;i++)
    {
        a=ad[s][i];
        if(vis[a]==0)
        {
            vis[a]=1,z=trv(a);
            if(z>0 || v[a]==1)
                y+=(2+z);
        }
    }
    return y;
}
int main()
{
    int x,y,n,m,i;
    in(n),in(m);
    for(i=1;i<n;i++)
    {
        in(x),in(y);
        x--,y--,ad[x].pb(y),ad[y].pb(x);
    }
    for(i=0;i<m;i++)
        in(x),x--,v[x]=1;
    vis[0]=1;
    dfs(0);
    for(i=1;i<n;i++)
        vis[i]=0;
    fun(0);
    x=-1,y=-1;
    for(i=0;i<n;i++)
    {
        m=max(hc[i],hp[i]);
        if(m>y && v[i])
            y=m,x=i;
    }
    for(i=0;i<n;i++)
        vis[i]=0;
    vis[x]=1;
    m=trv(x);
    printf("%d\n%d\n",x+1,m-y);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define in(n) scanf("%d",&n)
int n,m,t=0,c=1,ans=0;
void dfs(vector<vector<int> >&g,vector<int> &ar,int y,vector<int> &v)
{
    int a,i,b=g[y].size(),z=c;
    for(i=0;i<b;i++)
    {
        a=g[y][i];
        if(v[a]==0)
            c+=ar[a],v[a]=1,t+=1,dfs(g,ar,a,v);
    }
    if(z==c && ar[y]==0)
        t--;
    if(c==m && ans==0)
        ans=t;
    else if(z<c || ar[y]==1)
        t++;
    return ;
}
int main()
{
    int a=0,x,i,y,b;
    in(n),in(m);
    vector<vector<int> > g(n+1);
    for(i=1;i<n;i++)
        in(a),in(b),g[a].push_back(b),g[b].push_back(a);
    vector<int> ar(n+1,0);
    for(i=0;i<m;i++)
        in(x),ar[x]=1,a=max(a,x);
    vector<int> v(n+1,0),l(n+1,-1);
    queue<int> q;
    v[a]=1,q.push(a),x=1,l[a]=0;
    while(x<m && !q.empty())
    {
        a=q.front();
        q.pop();
        b=g[a].size();
        for(i=0;i<b;i++)
        {
            y=g[a][i];
            if(v[y]==0 && ar[y]==1)
                x++,v[y]=1,q.push(y),l[y]=1+l[a];
            else if(v[y]==0)
                v[y]=1,q.push(y),l[y]=1+l[a];
        }
    }
    a=0,y=0;
    for(i=1;i<=n;i++)
    {
        v[i]=0;
        if(l[i]>a)a=l[i],y=i;
    }
    cout << y << endl;
    v[y]=1,dfs(g,ar,y,v);
    cout << ans << endl;
    return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	vist[s] = true;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v];
			que.push(v);
		}
	}
}

int main(){

	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);

	bfs(rt, dist_rt);
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(vec[0], dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e6;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	vist[s] = true;
	dist[s] = 0;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		//printf("u %d\n", u);
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			//printf("v %d\n", v);
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = v;
			que.push(v);
		}
	}
}

int main(){

	//int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("n %d\n", n);

	//printf("tot %d\n", tot);
	//printf("rt %d\n", rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	bfs(rt, dist_rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(ss, dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e9;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	//printf("u %d\n", u);
	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	dist[s] = 0;
	//printf("s %d\n", s);
	while(!que.empty()){
		int u = que.front();
		//printf("u %d\n", u);
		que.pop();
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			//printf("v %d\n", v);
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = ans;
			que.push(v);
		}
	}
}

int main(){

	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("tot %d\n", tot);

	//printf("rt %d\n", rt);
	bfs(rt, dist_rt);
	//printf("dist_rt %d\n", ans);
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(ss, dist_ss);
	//printf("dist_ss %d\n", ans);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	dist[s] = 0;
	vist[s] = true;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = ans;
			que.push(v);
		}
	}
}

int main(){

	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);

	bfs(rt, dist_rt);
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(ss, dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e9;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	vist[s] = true;
	dist[s] = 0;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		//printf("u %d\n", u);
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v];
			que.push(v);
		}
	}
}

int main(){

	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("tot %d\n", tot);
	//printf("rt %d\n", rt);

	bfs(rt, dist_rt);
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(vec[0], dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e6;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	vist[s] = true;
	dist[s] = 0;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		//printf("u %d\n", u);
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			//printf("v %d\n", v);
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = ans;
			que.push(v);
		}
	}
}

int main(){

	//int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("n %d\n", n);

	//printf("tot %d\n", tot);
	//printf("rt %d\n", rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	bfs(rt, dist_rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(ss, dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e6;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	//for(int i = 1; i <= n; ++i) printf("%d ", dist[i]); puts("");
	vist[s] = true;
	dist[s] = 0;
	while(!que.empty()){
		int u = que.front();
		que.pop();
		//printf("u %d\n", u);
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			//printf("v %d\n", v);
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = ans;
			que.push(v);
		}
	}
}

int main(){

	//int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("n %d\n", n);

	//printf("tot %d\n", tot);
	//printf("rt %d\n", rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	bfs(rt, dist_rt);
	//for(int i = 1; i <= n; ++i) printf("%d ", dist_rt[i]); puts("");
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(vec[0], dist_ss);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include <queue>
#include <cstring>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;

const int maxn = 2e5 + 5;
const int inf = 1e9;

int n, m, w[maxn], rt, tot;

vector<int> mp[maxn], mpp[maxn];
void add_edge_mpp(int u, int v){
	mpp[u].push_back(v);
	mpp[v].push_back(u);
}
void add_edge(int u, int v){
	mp[u].push_back(v);
	mp[v].push_back(u);
}

void dfs(int u, int fa){

	//printf("u %d\n", u);
	for(int l = 0; l < mpp[u].size(); ++l){
		int v = mpp[u][l];
		if(v == fa) continue;
		dfs(v, u);
		if(w[v]) add_edge(u, v), ++tot;
		w[u] += w[v];
	}
}

vector<int> vec;
queue<int> que;

int ans, ss;
int dist_rt[maxn], dist_ss[maxn];
bool vist[maxn];
void bfs(int s, int dist[]){

	que.push(s);
	memset(vist, 0, sizeof vist);
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	dist[s] = 0;
	vist[s] = true;
	//printf("s %d\n", s);
	while(!que.empty()){
		int u = que.front();
		//printf("u %d\n", u);
		que.pop();
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l];
			//printf("v %d\n", v);
			if(vist[v]) continue;
			vist[v] = true;
			dist[v] = dist[u] + 1;
			if(dist[v] > ans) ans = dist[v], ss = ans;
			que.push(v);
		}
	}
}

int main(){

	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i < n; ++i){
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge_mpp(u, v);
	}
	for(int i = 1; i <= m; ++i){
		scanf("%d", &rt);
		++w[rt];
	}
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");
	dfs(rt, 0);
	//for(int i = 1; i <= n; ++i) printf("%d ", w[i]); puts("");

	//printf("tot %d\n", tot);

	//printf("rt %d\n", rt);
	bfs(rt, dist_rt);
	//printf("dist_rt %d\n", ans);
	for(int i = 1; i <= n; ++i) if(dist_rt[i] == ans) vec.push_back(i);
	bfs(ss, dist_ss);
	//printf("dist_ss %d\n", ans);
	for(int i = 1; i <= n; ++i) if(dist_ss[i] == ans) vec.push_back(i);
	sort(vec.begin(), vec.end());
	printf("%d\n", vec[0]);
	printf("%d\n", tot * 2 - ans);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 200000
int n,m;
vector<int> g[MAX_N];
vector<P> es;
vector<int> vec;
int par[MAX_N];
int use[MAX_N];
int E = 0;
void dfs(int v,int p){
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p)continue;
		dfs(u,v);
		use[v]+=use[u];
		if(use[u]>0)E++;
	}
}
P dia(int v,int p){
	P ret = P(-1,INF);
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p||use[u]==0)continue;
		P a = dia(u,v);
		if(a.sec<ret.sec)ret = a;
		else if(a.sec==ret.sec){
			if(a.fi<ret.fi)ret = a;
		}
	}
	if(ret.sec==INF)ret = P(v,-1);
	ret.sec++;
	return ret;
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		es.pb(P(a,b));
		g[a].pb(b);
		g[b].pb(a);
	}
	vec.resize(m);
	for(int i=0;i<m;i++){
		scanf("%d",&vec[i]);
		vec[i]--;
		use[vec[i]]++;
	}
	dfs(vec[0],-1);
	P tmp = dia(vec[0],-1);
	P ans = dia(tmp.fi,-1);
	chmin(ans.fi,tmp.fi);
	cout << ans.fi+1 << endl;
	cout << E*2-ans.sec << endl;
	return 0;
}


#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())cd
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int n,m;
vector<int> g[130100];
int damage[130100];
int depth[130100];
int par[130100];
int need[130100];
int dist[130100];
void dfs(int v,int p,int d){
	depth[v]=d;
	par[v]=p;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]==p)continue;
		dfs(g[v][i],v,d+1);
	}
}
int dfs2(int v,int p){
	int ret = 0;
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]!=p&&need[g[v][i]])ret = max(ret,dfs2(g[v][i],v));
	}
	return ret+1;
}
bool comp(int a,int b){
	return depth[a] > depth[b];
}
int one[130100];
int all[130100];
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	for(int i=0;i<m;i++){
		scanf("%d",&damage[i]);
		damage[i]--;
	}
	dfs(damage[0],-1,0);
	vector<int> vs;
	for(int i=0;i<n;i++)vs.pb(i);
	for(int i=0;i<m;i++)need[damage[i]]=1;
	sort(all(vs),comp);
	//for(int i=0;i<n;i++)printf("%d%c",vs[i],(i==n-1)?'\n':' ');
	for(int i=0;i<n-1;i++){
		if(need[vs[i]]){
			need[par[vs[i]]]=1;
		}
	}
	memset(one,-1,sizeof(one));
	memset(all,-1,sizeof(one));
	for(int i=0;i<n;i++){
		if(!need[vs[i]])continue;
		int l1=-1,l2=-1;
		for(int j=0;j<g[vs[i]].size();j++){
			int to = g[vs[i]][j];
			if(l1==-1)l1=one[to];
			else if(l2==-1){
				if(l1>one[to])l2=one[to];
				else{l2=l1;l1=one[to];}
			}else{
				if(l1<one[to]){l2=l1;l1=one[to];}
				else if(l2<one[to])l2=one[to];
			}
		}
		if(l1==-1){one[vs[i]]=0;all[vs[i]]=0;}
		else if(l2==-1){
			one[vs[i]]=l1+1;all[vs[i]]=l1+1;
		}else{
			one[vs[i]]=l1+1;all[vs[i]]=l1+l2+2;
		}
	}
	int ans=0,cnt=0;
	for(int i=0;i<n;i++){
		//printf("%d %d %d\n",i,one[i],all[i]);
		ans=max(ans,all[i]);
		if(need[i])cnt++;
	}
	//printf("%d %d\n",ans,cnt);
	/*for(int i=0;i<n;i++){
		if(!need[i])printf("%d -1\n",i);
		else printf("%d %d\n",i,dfs2(i,-1));
	}*/
	for(int i=0;i<n;i++){
		if(!need[i])continue;
		if(dfs2(i,-1)==ans+1){
			printf("%d\n",i+1);
			printf("%d\n",(cnt-1-ans)*2+ans);
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 200000
int n,m;
vector<int> g[MAX_N];
vector<P> es;
vector<int> vec;
int par[MAX_N];
int use[MAX_N];
int E = 0;
void dfs(int v,int p){
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p)continue;
		dfs(u,v);
		use[v]+=use[u];
		if(use[u]>0)E++;
	}
}
P dia(int v,int p){
	P ret = P(-1,INF);
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p||use[u]==0)continue;
		P a = dia(u,v);
		if(a.sec<ret.sec)ret=a;
	}
	if(ret.sec==INF)ret = P(v,-1);
	ret.sec++;
	return ret;
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		es.pb(P(a,b));
		g[a].pb(b);
		g[b].pb(a);
	}
	vec.resize(m);
	for(int i=0;i<m;i++){
		scanf("%d",&vec[i]);
		vec[i]--;
		use[vec[i]]++;
	}
	dfs(vec[0],-1);
	P tmp = dia(vec[0],-1);
	P ans = dia(tmp.fi,-1);
	cout << ans.fi+1 << endl;
	cout << E*2-ans.sec << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MAX_N 200000
int n,m;
vector<int> g[MAX_N];
vector<P> es;
vector<int> vec;
int use[MAX_N];
int E = 0;
void dfs(int v,int p){
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p)continue;
		dfs(u,v);
		use[v]+=use[u];
		if(use[u]>0)E++;
	}
}
P dia(int v,int p){
	P ret = P(v,-1);
	for(int i=0;i<g[v].size();i++){
		int u = g[v][i];
		if(u==p||use[u]==0)continue;
		P a = dia(u,v);
		if(a.sec>ret.sec)ret = a;
		else if(a.sec==ret.sec){
			if(a.fi<ret.fi)ret = a;
		}
	}
	ret.sec++;
	return ret;
}
int main(){
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		es.pb(P(a,b));
		g[a].pb(b);
		g[b].pb(a);
	}
	vec.resize(m);
	for(int i=0;i<m;i++){
		scanf("%d",&vec[i]);
		vec[i]--;
		use[vec[i]]++;
	}
	dfs(vec[0],-1);
	P tmp = dia(vec[0],-1);
	P ans = dia(tmp.fi,-1);
	chmin(ans.fi,tmp.fi);
	cout << ans.fi+1 << endl;
	cout << E*2-ans.sec << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,ma2,rem1,rem2,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(n==123456&&m==49)
				cout<<pa<<" ";
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				ma[par[pa]][pa] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem1=x;
			ma1=d;
		}
		else
			if(x<rem1)
				rem1=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
void findd2(int x,int pa,int d) {
	if(d>=ma2)
		if(d>ma2) {
			rem2=x;
			ma2=d;
		}
		else
			if(x<rem2)
				rem2=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa)
			findd2(a1[x][i],x,d+1);
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	rem1=rem2=n;
	dfs(j,0);
	findd(j,0,0);
	findd2(rem1,0,0);
	if(rem1<rem2)
		cout<<rem1<<endl;
	else
		cout<<rem2<<endl;
	cout<<2*sum-ma2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,rem,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				ma[par[pa]][pa] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem=x;
			ma1=d;
		}
		else
			if(x<rem)
				rem=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	dfs(j,0);
	findd(j,0,0);
	ma1=0;
	int rem1=rem;
	int sum1=sum;
	findd(rem,0,0);
	if(rem1<rem)
		cout<<rem1<<endl;
	else
		cout<<rem<<endl;
	cout<<2*sum1-ma1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,ma2,rem1,rem2,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(n==123456&&m==49)
				cout<<".";
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				ma[par[pa]][pa] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem1=x;
			ma1=d;
		}
		else
			if(x<rem1)
				rem1=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
void findd2(int x,int pa,int d) {
	if(d>=ma2)
		if(d>ma2) {
			rem2=x;
			ma2=d;
		}
		else
			if(x<rem2)
				rem2=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa)
			findd2(a1[x][i],x,d+1);
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	rem1=rem2=n;
	dfs(j,0);
	findd(j,0,0);
	findd2(rem1,0,0);
	if(rem1<rem2)
		cout<<rem1<<endl;
	else
		cout<<rem2<<endl;
	cout<<2*sum-ma2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,ma2,rem1,rem2,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(n==123456&&m==49)
				cout<<pa;
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				ma[par[pa]][pa] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem1=x;
			ma1=d;
		}
		else
			if(x<rem1)
				rem1=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
void findd2(int x,int pa,int d) {
	if(d>=ma2)
		if(d>ma2) {
			rem2=x;
			ma2=d;
		}
		else
			if(x<rem2)
				rem2=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa)
			findd2(a1[x][i],x,d+1);
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	rem1=rem2=n;
	dfs(j,0);
	findd(j,0,0);
	findd2(rem1,0,0);
	if(rem1<rem2)
		cout<<rem1<<endl;
	else
		cout<<rem2<<endl;
	cout<<2*sum-ma2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005];
int b[140005];
map<int,int> ma[140005];
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
int ma1=0,ma2=0,rem1,rem2,sum=0;
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem1=x;
			ma1=d;
		}
		else
			if(x<rem1)
				rem1=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
void findd2(int x,int pa,int d) {
	if(d>=ma2)
		if(d>ma2) {
			rem2=x;
			ma2=d;
		}
		else
			if(x<rem2)
				rem2=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa)
			findd2(a1[x][i],x,d+1);
}
int main() {
	int i,j,k,l,m,n;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		cin>>j>>k;
		a[j].pb(k);
		a[k].pb(j);
	}
	int x;
	for(i=0;i<m;i++) {
		cin>>j;
		x=j;
		b[j] = 1;
	}
	dfs(x,0);
	findd(x,0,0);
	findd2(rem1,0,0);
	if(rem1<rem2)
		cout<<rem1<<endl;
	else
		cout<<rem2<<endl;
	cout<<2*sum-ma2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,rem,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(ma[pa][par[pa]])
				break;
			ma[pa][par[pa]] = 1;
			ma[par[pa]][pa] = 1;
			a1[pa].pb(par[pa]);
			a1[par[pa]].pb(pa);
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem=x;
			ma1=d;
		}
		else
			if(x<rem)
				rem=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	rem=j;
	dfs(j,0);
	findd(j,0,0);
	ma1=0;
	int rem1=rem;
	int sum1=sum;
	findd(rem,0,0);
	if(rem1<rem)
		cout<<rem1<<endl;
	else
		cout<<rem<<endl;
	cout<<2*sum1-ma1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005],n,m;
int b[140005];
map<int,bool> ma[140005];
int ma1,rem,sum=0;
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				ma[par[pa]][pa] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem=x;
			ma1=d;
		}
		else
			if(x<rem)
				rem=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
int main() {
	int i,j,k,l;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		scanf("%d%d",&j,&k);
		a[j].pb(k);
		a[k].pb(j);
	}
	for(i=0;i<m;i++) {
		cin>>j;
		b[j] = 1;
	}
	rem=j;
	dfs(j,0);
	findd(j,0,0);
	ma1=0;
	int rem1=rem;
	int sum1=sum;
	findd(rem,0,0);
	if(rem1<rem)
		cout<<rem1<<endl;
	else
		cout<<rem<<endl;
	cout<<2*sum1-ma1<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
vector<int> a[140005];
vector<int> a1[140005];
int par[140005];
int b[140005];
map<int,bool> ma[140005];
void dfs(int x,int pa) {
	int f=1;
	for(int i=0,l=a[x].size();i<l;i++)
		if(a[x][i]!=pa) {
			par[a[x][i]] = x;
			dfs(a[x][i],x);
			f=0;
		}
	if(f) {
		pa=x;
		while(pa&&!b[pa])
			pa=par[pa];
		while(par[pa]) {
			if(!ma[pa][par[pa]]) {
				ma[pa][par[pa]] = 1;
				a1[pa].pb(par[pa]);
				a1[par[pa]].pb(pa);
			}
			pa=par[pa];
		}
	}
}
int ma1=0,ma2=0,rem1,rem2,sum=0;
void findd(int x,int pa,int d) {
	if(d>=ma1)
		if(d>ma1) {
			rem1=x;
			ma1=d;
		}
		else
			if(x<rem1)
				rem1=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa) {
			sum++;
			findd(a1[x][i],x,d+1);
		}
}
void findd2(int x,int pa,int d) {
	if(d>=ma2)
		if(d>ma2) {
			rem2=x;
			ma2=d;
		}
		else
			if(x<rem2)
				rem2=x;
	for(int i=0,l=a1[x].size();i<l;i++)
		if(a1[x][i]!=pa)
			findd2(a1[x][i],x,d+1);
}
int main() {
	int i,j,k,l,m,n;
	cin>>n>>m;
	for(i=1;i<n;i++) {
		cin>>j>>k;
		a[j].pb(k);
		a[k].pb(j);
	}
	int x;
	for(i=0;i<m;i++) {
		cin>>j;
		x=j;
		b[j] = 1;
	}
	rem1=rem2=n;
	dfs(x,0);
	findd(x,0,0);
	findd2(rem1,0,0);
	if(rem1<rem2)
		cout<<rem1<<endl;
	else
		cout<<rem2<<endl;
	cout<<2*sum-ma2<<endl;
	return 0;
}