#include using LL = long long; const int N = 2e5 + 7; const int L = 19; int n, m, a[N], sgsub[N], sg[N], f[N][L], g[N][L]; std::vector e[N]; void dfs(int x, int y) { for(int v: e[x]) if(v != y) { dfs(v, x); f[x][sgsub[v]] = 1; } while(f[x][sgsub[x]]) ++sgsub[x]; } void dfs2(int x, int y) { if(x == 1) { for(auto v: e[x]) { ++f[x][sgsub[v]]; g[x][sgsub[v]] = std::min(g[x][sgsub[v]], v); } sg[x] = sgsub[x]; } else { int sgy = sgsub[x] > sg[y] || f[y][sgsub[x]] > 1 ? sg[y] : sgsub[x]; ++f[x][sgy]; g[x][sgy] = y; for(auto v: e[x]) if(v != y) { ++f[x][sgsub[v]]; g[x][sgsub[v]] = std::min(g[x][sgsub[v]], v); } while(f[x][sg[x]]) ++sg[x]; } for(auto v: e[x]) if(v != y) dfs2(v, x); } int main() { scanf("%d%d", &n, &m); for(int i = 1; i <= m; ++i) scanf("%d", &a[i]); for(int i = 1, x, y; i < n; ++i) { scanf("%d%d", &x, &y); e[x].push_back(y); e[y].push_back(x); } dfs(1, 0); memset(f, 0, sizeof f); memset(g, 0x3f, sizeof g); dfs2(1, 0); int val = 0; for(int i = 1; i <= m; ++i) val ^= sg[a[i]]; if(!val) { puts("-1 -1"); return 0; } for(int i = 1; i <= m; ++i) if(f[a[i]][val ^ sg[a[i]]]) { printf("%d %d\n", i, g[a[i]][val ^ sg[a[i]]]); return 0; } assert(0); return 0; }