Three-way Branch#3568

Three-way Branch

7 seconds
64 megabytes
Very hard (≈2050)

There is a grid that consists of W \times H cells. The upper-left-most cell is . You are standing on cell and you are going to move to cell (W, H). You can only move to adjacent lower-left, lower or lower-right cells.

There are obstructions on several cells. You cannot move to them. You cannot move out the grid, either. Write a program that outputs the number of ways to reach (W, H) modulo . You can assume that there is no obstruction at .

Input

The first line contains three integers, the width , the height , and the number of obstructions . (1 \le W \le 75, 2 \le H \le 10^{18}, 0 \le N \le 30) Each of following lines contains integers, denoting the position of an obstruction (x_i, y_i).

The last test case is followed by a line containing three zeros.

Output

For each test case, print its case number and the number of ways to reach (W, H) modulo .

Examples

Example 1

Loading
Loading