8966: Counter Strike

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

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 ("��CS" for short, different from the game with the same name in reality). It is a two-player competition. One player acts as a terrorist ("T" for short), responsible for planting bombs. The other one acts as a counter terrorist ("��CT" 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 n hubs (numbered from 11 to n) and m 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 n vertices and m edges, without multiple-edges or self-loops.

The game is divided into three stages:

  1. Bomb planting stage: T will receive k activating components numbered from 11 to kT needs to select k different hubs ℎ1,ℎ2,...,ℎ�h1,h2,...,hk, and set the i-th activating component on the ℎ�hi-th hub.
  2. Bomb defusing stage: ��CT will receive a useful kit for free, and buy q useless kits numbered from 11 to q. 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 i-th useless kit can only remove the ℎ�hi-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 T will win. Otherwise, the bomb will be defused and ��CT will win.
figure

For example, the picture above shows a bomb with a circuit consisting of 1919 hubs and 2727 wires. T obtained 66 activating components and set them on hub 16,17,2,18,12,916,17,2,18,12,9��CT 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.
figure

Now Markyyz acts as T, and SPY acts as ��CT. Markyyz has placed k 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 �((�+�)log⁡�)O((n+m)logn). Can you help him to calculate the answer (in other word, the minimum value of q for ��CT to win the game) ?

输入格式

The first line of the input contains an integer t (1≤�≤5000)(1t5000), indicating the number of test cases.

In each test case:

The first line contains three integers �,�,�n,m,k (2≤�,�≤2×105,2≤�≤�)(2n,m2×105,2kn), indicating the number of hubs, the number of wires, and the number of activating components.

The next m lines, each line contains two integers �,�u,v (1≤�,�≤�,�≠�)(1u,vn,u=v), indicating a wire connected to the u-th hub and the v-th hub.

The next line contains k different integers ℎ1,ℎ2,...,ℎ�h1,h2,...,hk (1≤ℎ�≤�)(1hin). The i-th activating component is set in the ℎ�hi-th hub.

It is guaranteed that in all test cases ∑�,∑�≤106n,m106.

输出格式

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

输入样例 复制

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

输出样例 复制

2

分类标签