#P9806. Counter Strike

Counter Strike

Counter Strike

Problem Description

SPY likes useful algorithms, while Markyyz always learns useless algorithms. Although they learn different type of algorithms, they both like a computer game called Counter Strike ("CSCS" for short, different from the game with the same name in reality). It is a two-player competition. One player acts as a terrorist ("TT" for short), responsible for planting bombs. The other one acts as a counter terrorist ("CTCT" for short), responsible for defusing bombs. At the start of each game, the system generates a bomb with a circuit in it. The circuit consists of nn hubs (numbered from 11 to nn) and mm wires. Each wire connects two different hubs, any two hubs could be directly or indirectly connected by wires, and no two hubs are directly connected by more than one wire. In other word, the circuit can be regarded as an undirected graph with nn vertices and mm edges, without multiple-edges or self-loops . The game is divided into three stages:

  1. Bomb planting stage: TT will receive kk activating components numbered from 11 to kk. TT needs to select kk different hubs h1,h2,...,hkh_1,h_2,...,h_k, and set the ii-th activating component on the hih_i-th hub.
  2. Bomb defusing stage: CTCT will receive a useful kit for free, and buy qq useless kits numbered from 11 to qq. A useful kit can remove an arbitrary hub, while a useless kit can only remove a hub with an activating component in order, which means the ii-th useless kit can only remove the hih_i-th hub. Once a hub is removed, all wires directly connected to it will be cut off.
  3. Bomb activating stage: If any two activating components are connected directly or indirectly by wires, the bomb will be activated and TT will win. Otherwise, the bomb will be defused and CTCT will win. 图片 For example, the picture above shows a bomb with a circuit consisting of 1919 hubs and 2727 wires. TT obtained 66 activating components and set them on hub 16,17,2,18,12,916,17,2,18,12,9. CTCT can buy 22 useless kits to remove the 1616-th and the 1717-th hub, then remove the 55-th hub with a useful kit. 图片 Now Markyyz acts as TT, and SPY acts as CTCT. Markyyz has placed kk activating components . To save money for the future games, SPY wants to buy the minimum number of useless kits to defuse the bomb. Although SPY makes himself master of useful algorithms, he can't find the answer within the time complexity of O((n+m)logn)O((n+m)\log n). Can you help him to calculate the answer (in other word, the minimum value of qq for CTCT to win the game) ?

Input

The first line of the input contains an integer tt (1t5000)(1\leq t \leq 5000), indicating the number of test cases. In each test case: The first line contains three integers n,m,kn,m,k (2n,m2×105,2kn)(2\leq n,m\leq 2\times 10^5,2\leq k\leq n), indicating the number of hubs, the number of wires, and the number of activating components . The next mm lines, each line contains two integers u,vu,v (1u,vn,uv)(1\leq u,v\leq n, u \neq v), indicating a wire connected to the uu-th hub and the vv-th hub. The next line contains kk different integers h1,h2,...,hkh_1,h_2,...,h_k (1hin)(1\leq h_i\leq n). The ii-th activating component is set in the hih_i-th hub. It is guaranteed that in all test cases n,m106\sum n ,\sum m \leq 10^6.

Output

You need to output a single integer in one line, indicating the minimum value of qq for CTCT to win the game.

Sample Input

1
19 27 6
1 2
1 3
2 4
3 4
2 5
4 5
5 6
5 8
6 7
6 8
8 7
8 9
7 9
7 10
9 10
5 11
11 12
12 13
13 14
14 12
11 15
11 16
16 17
16 18
17 18
17 19
18 19
16 17 2 18 12 9

Sample Output

2

Source

2023“钉耙编程”中国大学生算法设计超级联赛(2)