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 CPP):

Solution:
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;

typedef ll number;
const ll MOD = 1000000009;
typedef vector<number> marray;
typedef vector<marray> matrix;
matrix ident(ll n) {
	matrix A(n, marray(n));
	for (int i = 0; i < n; ++i) A[i][i] = 1;
	return A;
}
// O( n^2 )
marray mul(const matrix &A, const marray &x) {
	marray y(A.size());
	for (int i = 0; i < A.size(); ++i)
		for (int j = 0; j < A[0].size(); ++j) {
			y[i] += A[i][j] * x[j];
			y[i] %= MOD;
		}

	return y;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
	matrix C(A.size(), marray(B[0].size()));
	for (int i = 0; i < C.size(); ++i)
		for (int j = 0; j < C[i].size(); ++j)
			for (int k = 0; k < A[i].size(); ++k) {
				C[i][j] += A[i][k] * B[k][j];
				C[i][j] %= MOD;
			}
	return C;
}
// O( n^3 log e )
matrix pow(const matrix &A, ll e) {
	return e == 0 ? ident(A.size()) :
		e % 2 == 0 ? pow(mul(A, A), e / 2) : mul(A, pow(A, e - 1));
}


int main() {
	ll W, H, N;
	ll count = 0;
	while (cin >> W >> H >> N, W != 0) {
		count++;
		marray M(W);
		M[0] = 1;
		matrix Po(W, marray(W));
		for (int y = 0;y<W;y++)
			for (int x = 0;x<W;x++)
				Po[y][x] = abs(y - x) <= 1;

		vector<P> ob(N);
		for (int i = 0;i<N;i++) {
			ll x, y;
			cin >> x >> y;
			x--; y--;
			ob[i] = P(y, x);
		}
		sort(ob.begin(), ob.end());
		ll now = 0;
		for (int i = 0;i<ob.size();i++) {
			M = mul(pow(Po, ob[i].first - now), M);
			M[ob[i].second] = 0;
			now = ob[i].first;
		}
		M = mul(pow(Po, H - 1 - now), M);
		cout << "Case " << count << ": " << M[W - 1] << endl;
	}
	return 0;
}
/*
3 5 3
1 4
2 3
3 1

*/