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 <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const LL MOD =1000000009;
int zz;
LL pe[100][10000];

void mulmatmat(LL *l, LL *r, LL *ans){
	REP(i,zz){
		FOR(j,i,zz){
			REP(k,zz){
				ans[i*75+j] = (ans[i*75+j]+l[i*75+k]*r[k*75+j])%MOD;
			}
			ans[j*75+i] = ans[i*75+j];
		}
	}
}

VLL mulmatvec(LL *l, VLL r){
	VLL ans(zz,0LL);
	REP(i,zz){
		REP(j,zz){
			ans[i]+=l[i*75+j]*r[j];
			ans[i]%=MOD;
		}
	}
	return ans;
}

VLL mulmatvec(LL k, VLL r){
	int i=0;
	VLL tr = r;
	while(k){
		if(k&1){
			tr=mulmatvec(pe[i], tr);
		}
		k>>=1;
		i++;
	}
	return tr;
}

int main(){
	int t=1;
	LL h,nb;
	while(scanf("%d%lld%lld",&zz,&h,&nb),zz){
		map<LL, VI> bar;
		VLL bary;
		memset(pe,0,sizeof(pe));
		REP(i,zz)FOR(j,max(0,i-1),min(zz,i+2))pe[0][i*75+j]=1LL;
		REP(i,65)mulmatmat(pe[i],pe[i],pe[i+1]);
		REP(i,nb){
			LL bx,by;
			scanf("%lld%lld",&bx,&by);
			bar[by].PB(bx);
			bary.PB(by);
		}
		bary.PB(h);
		SORT(bary);
		LL cur=1;
		VLL vec(zz,0);
		vec[0]=1LL;
		REP(i,bary.size()){
			LL p=bary[i]-cur;
			cur = bary[i];
			vec=mulmatvec(p,vec);
			REP(j,bar[cur].size())vec[bar[cur][j]-1]=0LL;
		}
		printf("Case %d: %lld\n", t++, vec[zz-1]);
	}
	return 0;
}