#P9878. Delivery Robot

Delivery Robot

Delivery Robot

Problem Description

A delivery robot is an autonomous machine designed to provide delivery services. On many campuses, these robots can offer significant convenience to students. A delivery robot typically integrates various assistance systems, such as collision avoidance systems. These systems should enable the robot to automatically avoid both static obstacles and other robots. Due to the non-immediate nature of velocity control, collision avoidance systems typically allocate a time interval Δt\Delta t. If a collision is predicted to occur within Δt\Delta t at the current velocity, the system adjusts the robot's velocity accordingly, including its speed and direction. We assume that the velocity can change instantly at the beginning of Δt\Delta t but remains constant throughout Δt\Delta t. In this problem, we set Δt=1\Delta t=1, meaning you only need to consider the first Δt=1\Delta t=1 from the initial position, without considering the subsequent process. We envision the delivery robot as a moving convex polygon on a two-dimensional plane with nn vertices, with its initial vertex coordinates given. In addition, there is a stationary convex polygonal obstacle on the plane with mm vertices, and its vertex coordinates are also given. As a developer of the collision avoidance system, you want to conduct qq tests, each time setting an initial velocity vector v\bf{v} for the robot, and the robot will start from the given initial position. According to the principle of the collision avoidance system, if the robot will collide with the obstacle after traveling for Δt=1\Delta t=1 at the current velocity, the robot's velocity should be changed immediately at the beginning, that is, v\bf{v} should be modified to v\bf{v}'. Without an upper limit on speed, it is evident that a suitable v\bf{v}' must exist to prevent a collision within Δt=1\Delta t=1. Depending on the situation, different strategies can be used to select v\bf{v}'. The objective of this problem is to choose a v\bf{v}' that minimizes the magnitude of the difference between v\bf{v} and v\bf{v}', i.e. $\bf{v}'=\arg\min_{\bf{u}}\Vert {\bf{v}}-{\bf{u}}\Vert$. The magnitude of a vector v=(x,y){\bf{v}}=(x,y) is defined as v=x2+y2\Vert{\bf{v}}\Vert=\sqrt{x^2+y^2}.

Input

The first line contains an integer TT (1T201\le T \le 20), indicating the number of test cases. The first line of each test case contains three integers n,m,qn,m,q (3n,m,q10003 \le n,m,q \le 1000), indicating the number of vertices of the delivery robot and the obstacle, respectively. Each of the next nn lines contains two integers x,yx,y (106x,y106-10^6 \le x,y \le 10^6), indicating the coordinates of a vertex of the delivery robot. The coordinates are given in counter-clockwise order. Each of the next mm lines contains two integers x,yx,y (106x,y106-10^6 \le x,y \le 10^6), indicating the coordinates of a vertex of the obstacle. The coordinates are given in counter-clockwise order. It is guaranteed that the delivery robot and the obstacle are strictly disjoint. Each of the next qq lines contains two integers x,yx,y (106x,y106-10^6 \le x,y \le 10^6), indicating the initial velocity vector v=(x,y){\bf{v}}=(x,y) of the delivery robot. It is guaranteed that n2000\sum n \le 2000 and m2000\sum m \le 2000 and q5000\sum q \le 5000 over all test cases.

Output

For each test, output the square of the minimum magnitude of vv{\bf{v}}-{\bf{v}}', i.e.minvv2\min\Vert{\bf{v}}-{\bf{v}}'\Vert^2, in a single line. You should output the answer as an irreducible fraction p/qp/q, where pp, qq are integers and q>0q > 0.

Sample Input

1
4 3 3
-1 -1
-2 -1
-2 -2
-1 -2
0 1
1 0
2 2
1 1
2 2
3 3

Sample Output

0/1
1/2
18/5

Hint

You can use __int128 in your C++ code.

Source

2023“钉耙编程”中国大学生算法设计超级联赛(8)