Friends or Enemies?

For each query number pair, find the points on a clockwise square spiral, then check whether they lie on the same side of a given line.

Medium6GeometryMathSimulationNo attempts yetTime limit2sMemory limit512 MB

Problem

An army stationed at a border decided to number the coordinates around it so that the enemy would have a hard time telling which positions it refers to if the radio signal used for communication were intercepted. The numbering works as follows. First, the army decides where the xx and yy axes lie. Next, it fixes a linear equation that describes the position of the border relative to the axes (the border is a straight line). Finally, it numbers every integer point of the Cartesian plane that is not on the border. The point (0,0)(0,0) gets the number 0, and from there the integer points are numbered along a clockwise spiral, always skipping the points that lie on the border (see Figure 1). If the point (0,0)(0,0) lies on the border, the number 0 goes to the first point in the given order that is not on the border.


Figure 1: Numbering of the integer points

As the figure shows, the spiral moves from (0,0)(0,0) to (1,0)(-1,0). For each integer k1k \ge 1, the points with max(x,y)=k\max(|x|,|y|) = k are visited starting at (k,k+1)(-k,-k+1), going up to (k,k)(-k,k), then right to (k,k)(k,k), then down to (k,k)(k,-k), then left to (k,k)(-k,-k). The spiral then repeats the same pattern for k+1k+1.

The enemy cannot tell which position the army refers to unless it knows the numbering system. The scheme also made life hard for the army, because it is now difficult to decide whether two given points are on the same side of the border or on opposite sides. That is where they need your help.

Input

The input contains several test cases. The first line holds an integer TT (1T1001 \le T \le 100), the number of test cases. The TT test cases follow.

The first line of each test case holds two integers aa and bb (5a5-5 \le a \le 5, 10b10-10 \le b \le 10) that describe the border equation y=ax+by = ax + b. The second line holds an integer KK (1K10001 \le K \le 1000), the number of queries that follow. Each of the next KK lines describes one query with two integers MM and NN (0M,N655350 \le M, N \le 65535), the numbers assigned to two points.

Output

For each test case, print K+1K+1 lines. The first line identifies the test case in the form Caso X, where XX is the test case number starting from 1. The next KK lines hold the answers to the KK queries in input order. If the points numbered MM and NN are on the same side of the border, print

Mesmo lado da fronteira

and otherwise print

Lados opostos da fronteira