Master Zhu and the Leaper

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Consider an n×mn \times m rectangular board consisting of square cells. Master Zhu put a leaper at position (1,1)(1, 1), which is the upper left cell.

The leaper is able to jump from position (x_1,y_1)(x\_1, y\_1) to position (x_2,y_2)(x\_2, y\_2) if and only if the positive integers x_1x\_1, y_1y\_1, x_2x\_2, and y_2y\_2 satisfy the following conditions:

(x_2x_1)2+(y_2y_1)2=5, x_2>x_1, y_2>y_1. \begin{array}{c} (x\_2 - x\_1)^2 + (y\_2 - y\_1)^2 = 5 \text{,} \\\ x\_2 > x\_1 \text{,} \\\ y\_2 > y\_1 \text{.} \\\ \end{array}

Unfortunately, there are some obstacles on the board. The leaper can never enter a square with an obstacle.

Master Zhu wants to move the leaper to position (n,m)(n, m), which is the lower right cell of the board, by making zero or more jumps. Help him find the number of ways the leaper can achieve its goal. As the answer may be very large, calculate it modulo 110,119110\\,119.

입력

The first line of input contains one integer TT, the number of test cases (1T5401 \le T \le 540).

The first line of each test case contains three integers nn, mm, and rr: the height of the board, the width of the board, and the number of obstacles on the board, respectively (1n,m10181 \leq n, m \leq 10^{18}, 0r1000 \leq r \leq 100).

Then follow rr lines. Each of them contains two integers xx and yy: coordinates of an obstacle (1xn1 \leq x \leq n, 1ym1 \leq y \leq m). It is guaranteed that all given obstacles are distinct, and the position (1,1)(1, 1) contains no obstacle.

출력

For each test case, print the answer modulo 110,119110\\,119.