#include <bits/stdc++.h>
using namespace std;
#define MAXN 100001
#define INF 10e6
int d[MAXN][MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
vector<int> shop;
int c;
for (int i = 0; i < k; ++i) {
cin >> c;
shop.emplace_back(c);
}
for (int i = 1; i < n + 1; ++i)
for (int j = 1; j < n + 1; ++j)
d[i][j] = INF;
int a, b;
for (int i = 0; i < m; ++i) {
cin >> a >> b;
d[a][b] = 1;
d[b][a] = 1;
}
for (int k = 1; k < n + 1; ++k) {
for (int i = 1; i < n + 1; ++i) {
for (int j = 1; j < n + 1; ++j) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
int dm;
for (int i = 1; i < n + 1; ++i) {
dm = INF;
for (auto s : shop) {
if (i != s)
dm = min(dm, d[i][s]);
}
cout << (dm == INF ? -1 : dm) << ' ';
}
}