Dragon country has N cities and M roads. The cities are numbered 1 through N, and each road joins two different cities. Every road can be walked in both directions.
K dragons live in the country. Dragon i lives in city Ci, starts with Si heads, and grows Ni new heads every minute while it is alive. A dragon with at least one head is alive, and a dragon whose heads are all cut off dies. A dead dragon never grows a head again.
You hire warriors to wipe the dragons out. You pick the starting city of every warrior, and from minute 1 on, each minute runs in this order.
Several dragons may live in one city, and several warriors may cut heads off the same dragon in the same minute. Warriors travel only along roads, so they cannot move between cities that no chain of roads connects.
You choose the starting city and every action of every warrior. Find the smallest number of warriors that kills all of the dragons within a finite number of minutes.
The input holds several test cases.
The first line of each test case has three integers N, M, K (1≤N≤300, 0≤M≤N(N−1), 1≤K≤1000). Each of the next M lines holds one road as two integers a, b (1≤a=b≤N), a road between city a and city b. The same pair of cities may be given more than once. Each of the next K lines holds one dragon, and line i has three integers Ci, Si, Ni (1≤Ci≤N, 1≤Si≤105, 0≤Ni≤105).
The line after the last test case is 0 0 0, and that line is not processed.
For each test case, print on one line the smallest number of warriors that kills all of the dragons.