Problem Statement
Amey is a student at Bayview Secondary School and like for any other filthy Bayview student, milk
tea is a staple drink. As for Amey, he especially likes potato juice taro milk tea. Being the taro milk
tea connoisseur he is, he will only drink milk tea with sugar concentrations ranging from to .
Around Bayview Secondary, there are different milk tea stores which are built beside each other, which each sell taro milk tea with a sugar concentration of . Additionally, each milk tea store has an effect rating to indicate the popularity of a milk tea store.
Recently, surveys have been conducted by certain milk tea vendors. The results of each survey indicate how much the concentration of sugar should increase by through an integer value. Other milk tea stores within the effect range (all milk tea stores units to the left and right up until store 1 or store . In other words, stores within the range ) will also follow suit by adding the same amount of sugar in hopes of more customers.
Find the number of milk tea stores that Amey will be willing to buy and drink taro milk tea from after all the surveys and sugar concentration adjustments.
Input Specification
The first line will be the number of milk tea stores near Bayview Secondary, n.
The next line of input will be Amey’s sugar concentration tolerance .
The next line will be integers, separated by a space, which represent the base sugar concentrations in the milk tea of each store ().
The next line will be integers, separated by a space, which represent the effect rating of each milk tea store ().
The next line contains the number , representing the number of surveys conducted by the nearby stores.
Finally, lines follow each containing two integers in the form , with representing the index of the store which conducted the survey, and representing the result of the survey.
Output Specification
Print out the number of milk tea stores that Amey is willing to drink from.
Subtasks
For all subtasks:
.
Subtask 1 [20%]
Subtask 2 [80%]
Sample Input
5
4 6
0 0 0 1 0
1 2 1 1 0
3
3 2
5 4
4 2
Sample Output
3