#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
vector <int>a[MAXN];
int n, m, dist[MAXN], k, p[MAXN];
queue <int> q;

int main(){
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> m >> k;
    for(int i = 1; i <= k ; i++) cin >> p[i];
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        a[x].push_back(y);
        a[y].push_back(x);
    }
    fill(dist + 1, dist + 1 + n, INT_MAX);
    q.push(n);
    dist[n] = 0;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(auto v : a[u]){
            if(dist[v] > dist[u] + 1){
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
    for(int i = 1; i <= k; i++) cout << dist[p[i]] << ' ';
    
}