#1217
Unrated
RELATIVNOST
시간 제한
4s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Dominik Gleich

Young Luka is an art dealer. He has N 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 i wants to purchase at most ai colored paintings and at most bi 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 C 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 C clients get at least one colored painting?” Help Luka and save him from his worries.

입력

The first line of input contains two integers N, C (1 ≤ N ≤ 100 000, 1 ≤ C ≤ 20). The second line of input contains N integers ai (1 ≤ ai ≤ 1 000 000 000). The third line of input contains N integers bi (1 ≤ bi ≤ 1 000 000 000).

The fourth line of input contains the number of requirement changes Q (1 ≤ Q ≤ 100 000). Each of the following Q lines contains three integers, the label of the person changing the requirements P (1 ≤ P ≤ N), the maximal number of colored paintings they want to purchase aP (1 ≤ aP ≤ 1 000 000 000) and the maximal number of black and white paintings they want to purchase bP (1 ≤ bP ≤ 1 000 000 000).

출력

The output must consist of Q lines where each line contains the number of different purchases modulo 10 007.

예제 입력 1

2 2
1 1
1 1
1
1 1 1

예제 출력 1

1

예제 입력 2

2 2
1 2
2 3
2
1 2 2
2 2 2

예제 출력 2

4
4

예제 입력 3

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

예제 출력 3

66
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.