Cuber QQ used to encounter such a problem: find the intersection of two infinitely long convex right prisms AA and BB. Actually this problem is also on HDU Online Judge, you can solve it afterwards if you are interested.
Cuber QQ quickly solved it, and thought it too easy because his program can handle more than that. So he modify it a little bit, by removing the constraints of ``convex'', that is, the cross-section of these two prisms are not necessarily convex, but they are still simple.
Formally, you have to find the volume of intersection of two prisms, whose cross-sections are both simple polygons. All joining edges of AA are parallel to the zz-axis, and all joining edges of BB are parallel to the xx-axis. If A and B do not intersect, the answer is 00 of course.
Input
The first line is an integer tt, denoting the number of test cases follows.
For each test case, there are two polygons, the base polygon of AA and BBrespectively.
An integer nn (3≤n≤1053≤n≤105) followed by nn lines, each containing two space-separated integers (x,y)(x,y) (−106≤x,y≤106−106≤x,y≤106), is the representation of the base polygon of AA. The following m+1m+1 (3≤m≤1053≤m≤105) gives a similar representation for BB, except that the coordinates given are (y,z)(y,z) (−106≤x,y≤106−106≤x,y≤106).
Each polygon are given in either clockwise or counterclockwise order. Following the convention, polygon PP is simple, if no two edges have any points in common, with the obvious exception of two consecutive segments having one common point.
The sum of m+nm+n from all test cases does not exceed 2⋅1062⋅106.
Output
For each test case, output the answer modulo 109+7109+7, that is, if the answer is PQPQ, you should output P⋅Q−1P⋅Q−1 modulo 109+7109+7, where Q−1Q−1 denotes the multiplicative inverse of QQ modulo 109+7109+7.