Problem: There is a grid that consists of W \times H cells. The upper-left-most cell is (1, 1). You are standing on the cell of (1,1) and you are going to move to cell of (W, 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 (W,H) modulo 1,000,000,009. You can assume that there is no obstruction at (1,1).



Input

The first line contains three integers, the width W, the height H, and the number of obstructions N. (1 \leq W \leq 75, 2 \leq H \leq 10^{18}, 0 \leq N \leq 30) Each of following N lines contains 2 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 1,000,000,009.

Example

Input

2 4 1
2 1
2 2 1
2 2
0 0 0


Output

Case 1: 4
Case 2: 0

Solution (in JAVA):

Solution:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		run();
	}

	static void run() {
		new Main().solver();
	}

	long MOD = 1_000_000_009;

	void solver() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			long w = sc.nextLong(), h = sc.nextLong();
			int n = sc.nextInt();
			if (w == 0 && h == 0 && n == 0)
				break;
			long[][] obs = new long[n][2];
			for (int i = 0; i < n; i++) {
				obs[i] = new long[] { sc.nextLong() - 1, sc.nextLong() - 1 };
			}
			Arrays.sort(obs, new Comparator<long[]>() {
				@Override
				public int compare(long[] o1, long[] o2) {
					return Long.compare(o1[1], o2[1]);
				}
			});
			long[][] ans = new long[(int) w][1];
			ans[0][0] = 1;
			long[][] A = new long[(int) w][(int) w];
			for (int i = 0; i < w; i++) {
				if (i < w - 1) {
					A[i][i + 1] = 1;
					A[i + 1][i] = 1;
				}
				A[i][i] = 1;
			}
			long cur_y = 0;
			for (int i = 0; i < n; i++) {

				ans = MtPow(obs[i][1] - cur_y, A, ans);
				// tr(ans);
				cur_y = obs[i][1];
				ans[(int) obs[i][0]][0] = 0;
			}
			ans = MtPow((h - 1) - cur_y, A, ans);
			System.out.println("Case " + (count++) + ": " + ans[(int) w - 1][0]);
		}
	}

	int count = 1;

	long[][] MtPow(long n, long[][] A, long[][] v) {
		for (; n > 0; n = n >> 1) {
			if ((n & 1) == 1)
				v = MtPrd(A, v);
			A = MtPrd(A, A);
		}
		return v;
	}

	long[][] MtPrd(long[][] A, long[][] B) {
		long[][] C = new long[A.length][B[0].length];
		for (int i = 0; i < A.length; i++) {
			for (int j = 0; j < B[0].length; j++) {
				for (int k = 0; k < A[0].length; k++) {
					C[i][j] += A[i][k] * B[k][j] % MOD;
					C[i][j] %= MOD;
				}
			}
		}
		return C;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}