#3765. Count

Count

Description

image

Format

Input

image

Output

image

Samples

3 2 0
2 1 2
1 1
1 3
0
3

Hint

M,N<=3*10^5,Ai<=10^9