#P3745. 「COCI 2015.10」RELATIVNOST

「COCI 2015.10」RELATIVNOST

Description

Young Luka is an art dealer. He has NN clients and sells artistic paintings to each client.
Each client can purchase either colored paintings or black and white paintings, but not both.
The client denoted with ii wants to purchase at most aia_i colored paintings and at most bib_i black and white paintings.
The client will always purchase at least one paintings. Luka has an almost unlimited amount of paintings, so the number of paintings required from the clients is never a problem.
Luka doesn’t like selling black and white paintings and knows that if less than CC people get colored paintings, it will make him feel sad.

His clients constantly keep changing their requests or, in other words, the number of paintings they want to purchase. Because of this, Luka is often troubled by the question: “How many different purchases are there, so that at least CC clients get at least one colored painting?” Help Luka and save him from his worries.

Input

The first line of input contains two integers N,CN, C (1N105,1C201 \leq N \leq 10^5, 1 \leq C \leq 20).
The second line of input contains NN integers aia_i (1ai1091 \leq a_i \leq 10^9).
The third line of input contains NN integers bib_i (1bi1091 \leq b_i \leq 10^9).

The fourth line of input contains the number of requirement changes QQ (1Q1051 \leq Q \leq 10^5).
Each of the following QQ lines contains three integers, the label of the person changing the requirements PP (1PN1 \leq P \leq N), the maximal number of colored paintings they want to purchase aPa_P (1aP1091 \leq a_P \leq 10^9) and the maximal number of black and white paintings they want to purchase bPb_P (1bP1091 \leq bP \leq 10^9).

Output

The output must consist of QQ lines where each line contains the number of different purchases modulo 1000710007.

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

Scoring

In test cases worth 30%30\% of total points, it will hold that NN and QQ are smaller than 10001000.