Smzzl with Safe Zone
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A boy, whose ID is smzzl, is playing a game named Zig-Zag-Land(ZZL). This is a 2D battle royale game. When the game starts, you will spawn in a random place in the map, and your target is to move into the safe zone.

Given the border of the map and the border of the safe zone, he wants to know the shortest distance between the spawn point and the safe zone in the worst case.

It can be proved that the square of the answer is always rational. In order to check your answer precisely, you need to print the square of your answer modulo

输入描述:

The input consists of multiple test cases.

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

For each test case:

In the first line, there is an integer , which is the number of vertexes of the safe zone.

In the next mm lines, each line contains two integers x_i,y_i(), which is a vertex of the safe zone.

In the next line, there is an integer , which is the number of vertexes of the game map.

In the next n lines, each line contains two integers x_i,y_i(), which is a vertex of the game map.

It is guaranteed that:
- The safe zone is a subset of game map.
- The safe zone and the game map are both convex polygons.
- All vertexes are given in counter-clockwise order.
- The sum of nn over all test cases will not exceed
- The sum of mm over all test cases will not exceed

You may need to use faster input method.

输出描述:

For each test case, output the square of your answer modulo .
示例1

输入

复制
1
4
0 0
1 0
1 1
0 1
4
-1 -1
2 -1
2 2
-1 2

输出

复制
2

备注:

Source 2021“MINIEYE杯”中国大学生算法设计超级联赛(7)