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<iostream>
#include<cstdio>
#include<bits/stdc++.h>	//for "geometry.cpp"
#include<iomanip>	//for "cout<<fixed<<setprecision(a number)<<sth<<endl;"
#include<queue>
#include<string>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<algorithm>
#include<functional>	//for "greater<type>"
#include<cmath>
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert	//tentative

typedef vector<long long> vec;//Be careful of the clash of type names, especially with vec in "geometry.cpp".
typedef vector<vec> mat;//The first index stands for linage.

const int M=1000000009;

mat mul(mat A,mat B){
	mat C(A.size(),vec(B[0].size()));
	for(int i=0;i<A.size();++i){
		fill(C[i].begin(),C[i].end(),0);
		for(int k=0;k<B.size();++k){
			for(int j=0;j<B[0].size();++j){
				C[i][j]+=A[i][k]*B[k][j];//Be careful of MAX_INT, types, etc.
				C[i][j]%=M;
			}
		}
	}
	return C;
}

mat pow(mat A,long long n){
	mat B(A.size(),vec(A.size()));
	for(int i=0;i<A.size();++i){
		fill(B[i].begin(),B[i].end(),0);
		B[i][i]=1;
	}
	while(n>0){
		if(n&1) B=mul(B,A);
		A=mul(A,A);
		n>>=1;
	}
	return B;
}

typedef pair<int,long long> pill;//You can add other pairs of types in the same way.

bool cmp(pill p,pill q){
	return p.sc<q.sc;
}

int c=0;

void solve(int w,long long h,int n){
	pill p[32];
	mat a(w,vec(1)),A(w,vec(w));
	p[0]=(mp(0,0));
	for(int i=1;i<=n;++i){
		cin>>p[i].fi>>p[i].sc;
		--p[i].fi;
		--p[i].sc;
	}
	cout<<"Case "<<++c<<": ";
	if(w>1){
		p[n+1]=(mp(0,h-1));
		sort(p+1,p+n+1,cmp);
		for(int i=0;i<w;++i){
			a[i][0]=0;
			for(int j=0;j<w;++j){
				if(abs(i-j)<=1) A[i][j]=1;
				else A[i][j]=0;
			}
		}
		a[0][0]=1;
		for(int i=1;i<=n+1;++i){
			while(p[i].sc==0) ++i;
			a=mul(pow(A,p[i].sc-p[i-1].sc),a);
			a[p[i].fi][0]=0;
			while(i<=n&&p[i].sc==p[i+1].sc) a[p[++i].fi][0]=0;
		}
		cout<<a[w-1][0]<<endl;
	}else{
		if(n>0){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}
}

int main(){
	while(true){
		int w,n;
		long long h;
		cin>>w>>h>>n;
		if(w==0) break;
		solve(w,h,n);
	}
}