Problems
Three-way Branch
Three-way Branch
There is a grid that consists of \textbf{W}×\textbf{H} cells. The upper-left-most cell is (\textbf{1}, \textbf{1}). You are standing on the cell of (\textbf{1}, \textbf{1}) and you are going to move to cell of (\textbf{W}, \textbf{H}). You can only move to adjacent lower-left, lower or lower-right cells.
There are obstructions on several cells. You can not move to it. You cannot move out the grid, either. Write a program that outputs the number of ways to reach (\textbf{W}, \textbf{H}) modulo \textbf{1000000009}. You can assume that there is no obstruction at (\textbf{1}, \textbf{1}).
\InputFile
The first line contains three integers, the width \textbf{W}, the height \textbf{H}, and the number of obstructions \textbf{N}. (\textbf{1} ≤ \textbf{W} ≤ \textbf{75}, \textbf{2} ≤ \textbf{H} ≤ \textbf{10^18}, \textbf{0} ≤ \textbf{N} ≤ \textbf{30}) Each of following \textbf{N} lines contains \textbf{2} integers, denoting the position of an obstruction (\textbf{x_i}, \textbf{y_i}).
The last test case is followed by a line containing three zeros.
\OutputFile
For each test case, print its case number and the number of ways to reach (\textbf{W}, \textbf{H}) modulo \textbf{1000000009}.
Input example #1
2 4 1 2 1 2 2 1 2 2 0 0 0
Output example #1
Case 1: 4 Case 2: 0