animeshops (NOINordic contest)
Time limit: 1 seconds | Memory limit: 512 MB | Task type: batch
Algorithms: shortest path, bfs, graph theory

# NOI 2024 Anime Shops

[TASK](https://cses.fi/495/task/A/) | [SUBMIT](https://cses.fi/495/submit/A/) | [RESULTS](https://cses.fi/495/view/A/)

**Time limit:** 1.00 s

**Memory limit:** 512 MB

There are *n* cities and *m* roads. Each road is bidirectional and connects two cities. It is also known that *k* cities have an anime shop.

If you live in a city, you of course know the local anime shop well if there is one. You would like to find the nearest anime shop that is not in your city.

For each city, determine the minimum distance to another city that has an anime shop.

### Input

The first line has three integers *n*, *m* and *k*: the number of cities, roads and anime shops. The cities are numbered 1, 2, ..., *n*.

The next line contains *k* integers: the cities that have an anime shop.

Finally, there are *m* lines that describe the roads. Each line has two integers *a* and *b*: there is a road between cities *a* and *b*.

### Output

Print *n* integers: for each city, the minimum distance to another city with an anime shop. If there is no such city, print -1 instead.

### Example

Input:

```
9 6 4
2 4 5 7
1 2
1 3
1 8
2 4
3 4
5 6
```

Output:

```
1 1 1 1 1 1 -1 1 -1
```

### Tasks

**A** [Anime Shops](https://cses.fi/495/task/A/)

**B** [Chair Game](https://cses.fi/495/task/B/)

**C** [Thin Ice](https://cses.fi/495/task/C/)

### Your submissions

### Subtask 1 (23 points)

*   1 ≤ *k* ≤ *n* ≤ 1000
*   0 ≤ *m* ≤ 2000

### Subtask 2 (16 points)

*   1 ≤ *k* ≤ *n* ≤ 10<sup>5</sup>
*   *m* = *n* - 1
*   Each road is between cities *i* and *i* + 1 for *i* = 1, 2, ..., *n* - 1

### Subtask 3 (61 points)

*   1 ≤ *k* ≤ *n* ≤ 10<sup>5</sup>
*   0 ≤ *m* ≤ 2 ⋅ 10<sup>5</sup>

Starter code:

Grader code:

Setup script:

Evaluation script: