## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Kirill and Company Codeforces Solution

G. Kirill and Company
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Kirill lives on a connected undirected graph of $n$ vertices and $m$ edges at vertex $1$. One fine evening he gathered $f$ friends, the $i$-th friend lives at the vertex ${h}_{i}$. So all friends are now in the vertex $1$, the $i$-th friend must get to his home to the vertex ${h}_{i}$.

The evening is about to end and it is time to leave. It turned out that $k$ ($k\le 6$) of his friends have no cars, and they would have to walk if no one gives them a ride. One friend with a car can give a ride to any number of friends without cars, but only if he can give them a ride by driving along one of the shortest paths to his house.

For example, in the graph below, a friend from vertex ${h}_{i}=5$ can give a ride to friends from the following sets of vertices: $\left[2,3\right]$$\left[2,4\right]$$\left[2\right]$$\left[3\right]$$\left[4\right]$, but can't give a ride to friend from vertex $6$ or a set $\left[3,4\right]$.

The vertices where friends without cars live are highlighted in green, and with cars — in red.

Kirill wants as few friends as possible to have to walk. Help him find the minimum possible number.

Input

The first line of input data contains an integer $t$ ($1\le t\le {10}^{3}$) — the number of test cases in the test.

The first line of the test case contains two integers $n$ and $m$ ($2\le n\le {10}^{4}$$n-1\le m\le min\left({10}^{4},$$\frac{n\cdot \left(n-1\right)}{2}$$\right)$) — the number of vertices and edges, respectively.

The next $m$ lines of the test case contain a description of the edges, two integers each $u$ and $v$ ($1\le u,v\le n$$u\ne v$) — indexes of vertices connected by an edge. It is guaranteed that there is at most one edge between any pair of vertices (i.e. no multiple edges in the graph).

Then follows line containing the number $f$ ($1\le f\le {10}^{4}$) — the number of Kirill's friends.

The next line of the test case contains $f$ integers: ${h}_{1},{h}_{2},\dots ,{h}_{f}$ ($2\le {h}_{i}\le n$) — the vertices in which they live. Some vertices may be repeated.

The next line of the set contains the number $k$ ($1\le k\le min\left(6,f\right)$) — the number of friends without cars.

The last line of each test case contains $k$ integers: ${p}_{1},{p}_{2},\dots ,{p}_{k}$ ($1\le {p}_{i}\le f$${p}_{i}<{p}_{i+1}$) — indexes of friends without cars.

It is guaranteed that the sum of $n$ over all cases does not exceed ${10}^{4}$, as well as the sums of $m$ and $f$.

Output

Output $t$ lines, each of which contains the answer to the corresponding test case. As an answer, output a single integer — the minimum possible number of friends who will have to walk.