#P17156. [ICPC 2017 Xi'an R] LOVER II
[ICPC 2017 Xi'an R] LOVER II
Problem Description
One day girls and boys come to Xi'an to look for a mate. Each girl has a value , each boy has a value . Girl and boy will fall in love only if .
Then queries follow. Ask you to calculate if we only have boys labeled from to , can we make all girls find their lovers?
Input Format
Several test cases (no more than ).
First line an integer . Indicates the number of test cases.
Then test cases follow. Each test case begins with three integers . The next line has integers indicating to . The next line has integers indicating to .
Then comes an integer . .
The next lines each contain two integers indicating each query.
Output Format
For each query, print "1" if we can make it or "0" otherwise.
1
3 4 5
1 1 1
4 4 4 3
2
1 3
2 4
1
0