Dangerous friends
Limits: 3 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Your city has been placed under quarantine — from now on, no one can leave or enter it. At the time the quarantine was introduced, there were \(n\) people living in the city, and some pairs of them are friends and interact with each other every day. Since all the residents of your city are very responsible citizens, on the very first day of quarantine all of them underwent appropriate testing and publicly announced its results. Thus, you know which of the city residents are sick on the first day after the introduction of quarantine. However, the disease spreads very quickly, so there is a high risk of getting infected upon contact with an already sick person.
Despite the fact that you are definitely not sick, as a responsible person you are deeply concerned and decided to protect yourself. To do this, you will cut off communication with some of your friends in order to prevent the possibility of infection. Currently, you need to decide with whom exactly you will stop interacting starting today.
So help yourself — write a program for this!
Input
The first line contains three integers \(n\), \(m\), \(k\) — the number of people in the city (including you), the number of pairs of friends among these people, and the number of sick people among them at the initial time moment.
The next \(m\) lines contain pairs of integers \(u_i, v_i\) — people with the corresponding numbers are friends.
The last line contains \(k\) numbers — the numbers of people who are sick at the initial time moment.
Note that your ID number is always equal to 1, and you are definitely healthy at the beginning of the quarantine.
Output
In the first line, print an integer — the minimum number of friends with whom you should stop communicating.
In the second line, print the numbers of these friends in ascending order.
Constraints
\(2 \le n\),
\(1 \le m\),
\(0 \le k \le n - 1\),
5 tests: \(n, m \le 100\),
5 tests: \(n, m \le 10^3\),
10 tests: \(n, m \le 10^5\),
5 tests: \(n, m \le 5 \cdot 10^5\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 6 6 2 1 2 2 3 4 5 4 1 5 1 1 6 3 6 | 2 2 6 |
| Input (stdin) | Output (stdout) |
|---|---|
| 5 6 1 1 2 1 3 1 4 2 3 3 4 4 5 5 | 3 2 3 4 |
Notes
In the first example, there are 6 people and 6 pairs of friends. Besides this, you know that people with numbers 3 and 6 were sick on the first day of quarantine. Of course, you will stop communicating with person number 6, as well as with 2, because this person can be infected since they communicate with a sick person (number 3). Note that you can continue to communicate with people 4 and 5, because they cannot get sick in any way. Also, you should not specify person 3 in the answer, because even before the quarantine you did not communicate with them.
In the second example, you should stop communicating with all your friends, because all of them will become infected after a certain time.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|