#abc190c. [abc190_c]Bowls and Dishes

[abc190_c]Bowls and Dishes

Problem Statement

We have NN dishes numbered 1,2,dots,N1, 2, \\dots, N and MM conditions numbered 1,2,dots,M1, 2, \\dots, M.
Condition ii is satisfied when both Dish AiA_i and Dish BiB_i have (one or more) balls on them.
There are KK people numbered 1,2,dots,K1, 2, \\dots, K. Person ii will put a ball on Dish CiC_i or Dish DiD_i.
At most how many conditions will be satisfied?

Constraints

  • All values in input are integers.
  • 2N1002 ≤ N ≤ 100
  • 1M1001 ≤ M ≤ 100
  • 1Ai<BiN1 ≤ A_i < B_i ≤ N
  • 1K 161 ≤ K ≤ 16
  • 1Ci<DiN1 ≤ C_i < D_i ≤ N

Input

Input is given from Standard Input in the following format:

NN MM A1A_1 B1B_1 vdots\\vdots AMA_M BMB_M KK C1C_1 D1D_1 vdots\\vdots CKC_K DKD_K

Output

Print the answer.


Sample Input 1

4 4
1 2
1 3
2 4
3 4
3
1 2
1 3
2 3

Sample Output 1

2

For example, if People 1,2,31, 2, 3 put their balls on Dishes 1,3,21, 3, 2, respectively, Conditions 11 and 22 will be satisfied.


Sample Input 2

4 4
1 2
1 3
2 4
3 4
4
3 4
1 2
2 4
2 4

Sample Output 2

4

For example, if People 1,2,3,41, 2, 3, 4 put their balls on Dishes 3,1,2,43, 1, 2, 4, respectively, all conditions will be satisfied.


Sample Input 3

6 12
2 3
4 6
1 2
4 5
2 6
1 5
4 5
1 3
1 2
2 6
2 3
2 5
5
3 5
1 4
2 6
4 6
5 6

Sample Output 3

9