Three-way Branch

Count three-way downward paths from (1,1) to (W,H) on a grid with up to 30 blocked cells, modulo 1000000009.

Medium7Dynamic programmingMatrixNo attempts yetTime limit7sMemory limit64 MB

Problem

There is a grid of WW columns and HH rows. The upper left cell is (1,1)(1, 1): the first coordinate grows to the right and the second coordinate grows downward. You stand on (1,1)(1, 1) and you want to reach (W,H)(W, H).

From cell (x,y)(x, y) you may move only to the cell below and to the left (x1,y+1)(x - 1, y + 1), the cell directly below (x,y+1)(x, y + 1), or the cell below and to the right (x+1,y+1)(x + 1, y + 1).

Some cells hold an obstruction. You cannot move onto an obstructed cell, and you cannot leave the grid. Write a program that prints the number of paths reaching (W,H)(W, H), modulo 1,000,000,009. The cell (1,1)(1, 1) never holds an obstruction.

Input

The input holds several test cases.

The first line of each test case has the width WW, the height HH, and the number of obstructions NN, separated by spaces. (1W751 \le W \le 75, 2H10182 \le H \le 10^{18}, 0N300 \le N \le 30)

Each of the next NN lines has the position xix_i, yiy_i of one obstruction. (1xiW1 \le x_i \le W, 1yiH1 \le y_i \le H)

The line after the last test case holds three zeros.

Output

For each test case, print one line with the case number and the number of paths reaching (W,H)(W, H), modulo 1,000,000,009. If the answer of the kk-th test case is aa, print it in the form Case k: a.