    #include <bits/stdc++.h>
    using namespace std;
    #include <math.h>
    #include <iomanip>
    #include <cstdint>
    #include <string>
    #include <sstream>
    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
    #define rep(i,n) for (int i = 0; i < (n); ++i)
    typedef long long ll;
    using P = pair<ll,ll>;
    const int mod=998244353;
    const int INF=1001001001;
    
    struct edge{
      int to;
      ll w;
      edge(int to,ll w):to(to),w(w){}
    };
    using Graph=vector<vector<edge>>;
    
    int N,M;
    
    void dijkstra(int s,Graph G,vector<ll>& dist){
      dist.resize(N,INF);
      dist[s]=0;
      priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>>q;
      q.push({dist[s],s});
      while(!q.empty()){
        int v=q.top().second;
        ll d=q.top().first;
        q.pop();
        if(d>dist[v]){continue;}
        for(auto e:G[v]){
          if(chmin(dist[e.to],dist[v]+e.w)){
            q.push({dist[e.to],e.to});
          }
        }
      }
    }

    int main() {
      cin>>N>>M;
      Graph G(N);
      rep(i,M){
        ll A,B;
        cin>>A>>B;
        A--;B--;
        G[A].push_back(edge(B,1));
        G[B].push_back(edge(A,1));
      }
      int K;
      cin>>K;
      vector<int>C(K);
      rep(i,K){cin>>C[i];C[i]--;}

      vector<vector<int>>dist(K);
      rep(i,K){
        vector<ll>d(N,INF);
        dijkstra(C[i],G,d);
        rep(j,K){dist[i].push_back(d[C[j]]);}
      }
      vector<vector<ll>>dp(1<<K,vector<ll>(K,INF));
      rep(i,K){dp[1<<i][i]=0;}
      rep(s,1<<K){
        rep(i,K){
          if((s>>i)&1){
            ll res=s^(1<<i);
            rep(j,K){
              if(res&(1<<j)){chmin(dp[s][i],dp[res][j]+dist[i][j]);}
            }
          }
        }
      }
      ll ans=*min_element(dp.back().begin(),dp.back().end());
      cout<<(ans<INF?ans+1:-1)<<endl;
      return 0;
    }
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
*/
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rrep(i,a,b) for(ll i=a;i>=b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll INF = 1e18+7;
const ll mod = 1e9+7;
const ll MAXN = 1e7+10;

ll poww(ll a, ll b) {    
    if(b<0) return 0LL;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        a = a * a;
        b >>= 1;
    }   
    return ans;
}
ll binpow(ll a, ll b, ll m) 
{
    if (b < 0) return 0LL;
    if (a <= 0)return 0LL;
    a %= m;
    
    ll ans = 1LL;
    while (b) {
        if (b & 1)ans = ans * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll n) {
    return binpow(n, mod - 2, mod);
}

vector<vector<ll>> adj;
vector<ll> res,ans;

void dfs(ll u, ll p, ll c[]) {
    if(res[c[u]]==0) ans.pb(u);
    res[c[u]]++;
    for(ll v : adj[u]) {
        if(v!=p) {
            dfs(v,u,c);
        }
    }
    res[c[u]]--;
}

void solve() {
    ll n; cin>>n;
    adj.resize(n+1);
    ll c[n+1]; FOR(i,n) cin>>c[i+1];
    res.assign(1e5+10,0);
    FOR(i,n-1) {
        ll x,y; cin>>x>>y;
        adj[x].pb(y); adj[y].pb(x);
    }
    dfs(1LL,-1,c);
    sort(all(ans));
    for(ll v : ans) cout<<v<<"\n";
}

int main() {
    IOS; 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    //ll no_of_test_cases; cin>>no_of_test_cases; 
    ll no_of_test_cases = 1;
    for(ll i=1; i<=no_of_test_cases; i++) {
        //cout<<"Case #"<<i<<": ";
        solve();
    } 
    return 0; 
}

