There are n spies(number of 1~n), some spies know who is spy. There are j spies can be caught, each cost \(w_i\). Once these spy are caught, they will tell out all the spies he know. If all the spies can be caught, please output the minimum cost, otherwise, please output the minimum No. of the spies which cannot be caught.
The first line contains an integer n \((1\leq n \leq 100000)\), indicating there are n spies in total.
The second line contains an integer j \((1\leq j \leq n)\), indicating there are j spies can be caught directly.
The next j lines, each line contains two integers b, w \((1\leq b \leq n, 1\leq w \leq 1000)\), indicating catch spy_b directly need cost w.
The next line contains an integer k \((1\leq k \leq 100000)\),
The next k lines, each line contains two integer u, v, \((1\leq u, v \leq n)\), indicating spy_u knows the information of spy_v.
If all the spies can be caught, please output YES in the first line and output the minimum cost in the second line.
If not all the spies can be caught, please output NO in the first line and output the minimum No. in the second line.