**Code A Thon SOLUTION **

**Code A Thon SOLUTION**

Problem Statement

In a City, there are N trucks and M set of streets where every street has a similar source and a similar objective. You are given P licenses in the city that is a truck An is allowed to go on Road B.

Every street has a limitation on the quantity of trucks that can go on it. This confined number is known as Capacity[i].

Because of the helpless state of the streets, consistently 1 specific street’s ability decreases by a number K. The information is known for X years.

For every year before the decrease happens, you have to foresee the most extreme number of trucks that can go in the city.

Imperatives:

1<= N,M <= 2000

1 <= P <= 10000

1 <= X <= 5000

1 <= A <= N

1 <= B,R <= M

0 <= Capacity[i], K <= 20

Information Format

First-line contains 3 whole numbers N, M, and P.

Next P lines contain 2 numbers An and B indicating that Ath truck is allowed on Bth street.

At that point there is a variety of size M comprising of Capacity[i].

At that point there is a number X (number of years for which the data is given).

At that point X lines contain 2 numbers R and K indicating Road R’s ability diminishes by K.

Yield Format

Print X lines containing the most extreme number of trucks that can go in the city.

Test Testcase #0

Testcase Input

3 4 5

1

1 2

2

2 4

3 4

3 2 5 3

7

3 4

2 1

1 3

4 2

2 1

4 1

3 1

Testcase Output

3

3

3

3

2

1

0

Clarification

Prior to Year 1 decrease > Send truck 1 on street 1,truck 2 on street 2,truck 3 on street 4.

Prior to Year 4 decrease – > Send truck 1 on street 2,truck 3 on street 4.

Prior to Year 7 decrease – > just street 3 has limit 1.But since no trucks are allowed on street 3 so you can not permit any truck. C 01 Hrs 40 Min 57 Sec