3024: Arrays

时间限制:16000 ms 内存限制:512 MB
上传者:
提交:10 通过:8

题目描述

Given two arrays $A$ and $B$, both of them have $n$ elements. Then there are $m$ queries, each of which contains four integers: $L$, $R$, $x$, $y$. For each query, you are required to count different indexes $k \in [L, R]$, that satisfy $A[k] \geq x$ and $B[k] \geq y$.

输入格式

The first line contains an integer number T, the number of test cases.

For each test case :
The first line contains two integers $n$, $m$($1 \leq n, m \leq 10^{5}$).

The second line contains $n$ integers $A[i]$($1 \leq A[i] \leq 10^{5}$).

The third line contains $n$ integers $B[i]$($1 \leq B[i] \leq 10^{5}$).

i-th of each next $m$ lines contains four integers $L$, $R$, $x$, $y$($1 \leq L \leq R \leq n, 1 \leq x, y \leq 10^{5}$).

输出格式

For each query print the answer.

输入样例 复制

1
5 5
1 2 3 4 5
7 6 5 4 3
1 2 1 1
1 5 1 1
2 4 3 4
2 2 2 6
3 3 3 3

输出样例 复制

2
5
2
1
1