Under construction

Still being built. Things may change

Postcards

Interview

Time limit1sMemory limit1024 MB

Summary
Count the friends reachable from Linas's close friends through known-each-other links, since every reached friend must also get a postcard.
Level

Easy3 of 10

Topics
Graph, BFS
Solved
No attempts yet

Statement

Linas has NN friends, and MM of them are close friends. Some of Linas's friends also know each other.

Before Easter, Linas wants to draw one postcard for each of his close friends. However, Linas knows that if a friend receives a postcard, every other friend who knows that friend will envy them, unless they also receive a postcard.

"It is better to draw than to envy," Linas thinks. So he wants to draw as many postcards as needed so that:

  1. every close friend of Linas receives a postcard,
  2. no friend envies another friend.

For example, suppose Linas has three friends, Domas, Tomas and Vytautas, but only Domas is a close friend. If Tomas and Domas know each other, Linas also draws a postcard for Tomas. If Tomas and Vytautas know each other too, Linas also draws a postcard for Vytautas, so that he does not envy Tomas.

You are given Linas's friends, his close friends, and which friends know each other. Find how many postcards Linas must draw so that all his close friends receive one and no friend envies another.

Input

The first line contains three integers NN, MM and KK: the number of friends, the number of close friends, and the number of pairs of friends who know each other. The friends are numbered from 11 to NN.

The next MM lines contain the numbers aia_i (1≤ai≤N1 \le a_i \le N) of the close friends.

Each of the next KK lines contains a pair (bj,cj)(b_j, c_j) meaning that friends bjb_j and cjc_j know each other, where bj≠cjb_j \neq c_j.

Output

Print one integer: the total number of postcards Linas must draw so that all of his close friends receive one and no friend envies another.

Constraints

1≤M≤N≤10001 \le M \le N \le 1000

0≤K≤1000000 \le K \le 100000

Examples1

  1. Example 1

    Input
    5 2 3
    2
    4
    1 2
    2 4
    5 1
    
    Expected output
    4