#715
Unrated
The Best Subsequence
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John has a binary string of length NN (1N109)(1 \leq N \leq 10^9), initially all zeros.

He will first perform MM (1M21051 \leq M \leq 2 \cdot 10^5) updates on the string, in order. Each update flips every character from ll to rr. Specifically, flipping a character changes it from 00 to 11, or vice versa.

Then, he asks you QQ (1Q21051 \leq Q \leq 2 \cdot 10^5) queries. For each query, he asks you to output the lexicographically greatest subsequence of length kk comprised of characters from the substring from ll to rr. If your answer is a binary string s1s2sks_1s_2 \dots s_k, then output i=0k12iski\sum_{i=0}^{k-1} 2^i \cdot s_{k-i} (that is, its value when interpreted as a binary number) modulo 109+710^9+7.

A subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.

Recall that string AA is lexicographically greater than string BB of equal length if and only if at the first position ii, if it exists, where AiBiA_i \neq B_i, we have Ai>BiA_i > B_i.

입력

The first line contains NN, MM, and QQ.

The next MM lines contain two integers, ll and rr (1lrN1 \leq l \leq r \leq N) — the endpoints of each update.

The next QQ lines contain three integers, ll, rr, and kk (1lrN,1krl+11 \leq l \leq r \leq N, 1 \leq k \leq r - l + 1) — the endpoints of each query and the length of the subsequence.

출력

Output QQ lines. The iith line should contain the answer for the iith query.

예제 입력 1

5 3 9
1 5
2 4
3 3
1 5 5
1 5 4
1 5 3
1 5 2
1 5 1
2 5 4
2 5 3
2 5 2
2 5 1

예제 출력 1

21
13
7
3
1
5
5
3
1

예제 입력 2

9 1 1
7 9
1 8 8

예제 출력 2

3

예제 입력 3

30 1 1
1 30
1 30 30

예제 출력 3

73741816

점수

Input 4: N10,Q1000N \leq 10, Q \leq 1000 Input 5: M10M \leq 10 Inputs 6-7: N,Q1000N, Q \leq 1000 Inputs 8-12: N2105N \leq 2 \cdot 10^5 Inputs 13-20: No additional constraints.

코드 제출

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

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