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 <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

const long long M=1e9+9;
typedef vector<long long> vec;
typedef vector<vec> mat;
struct Matrix{
  int N;
  mat a;
  Matrix(int n){
    N=n;
    a=mat(N,vec(N));
    for(int i=0;i<N;i++)a[i][i]=1;
  }
Matrix pow(long long b) const {
  Matrix res(N);
  Matrix d(N);
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[i][j]=a[i][j];
    for(;b>0;b>>=1,d=d*d)if(b&1)res=d*res;
      return res;
  }
  Matrix operator+(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        s[i][j]=(a[i][j]+r.a[i][j])%M;
      }
    }
    return s;
  }
  Matrix operator*(const Matrix& r) const {
    Matrix s(N);
    for(int i=0;i<N;i++)s[i][i]=0;
      const long long modl=8*M*M;
    for(int i=0;i<N;i++){
      for(int k=0;k<N;k++){
        for(int j=0;j<N;j++){
          s[i][j]+=a[i][k]*r.a[k][j];
          if(s[i][j]>=modl)s[i][j]-=modl;
        }
      }
      for(int j=0;j<N;j++)s[i][j]%=M;
    }
  return s;
}

vector<long long>& operator[](int i){
  return a[i];
}
};

int main(){

  int hoge=1;
  while(1){
    ll W,H,N;
    vector<ll> ev;
    map<P,bool> dame;
    cin>>W>>H>>N;
    if(W==0)break;
    rep(i,N){
      ll x,y;
      cin>>x>>y;
      y--; x--;
      dame[P(y,x)]=true;
      ev.push_back(y);
    }
    ev.push_back(0);
    ev.push_back(H-1);
    sort(all(ev));
    uni(ev);

    Matrix a(W);
    rep(i,W){
      rep(j,W){
        if(abs(i-j)<=1)a[i][j]=1;
        else a[i][j]=0;
      }
    }

    Matrix crt(W);
    rep(e,ev.size()-1){
      Matrix b(W);
      rep(i,W){
        rep(j,W){
          if(abs(i-j)<=1&&!dame[P(ev[e+1],j)])b[i][j]=1;
          else b[i][j]=0;
        }
      }
      Matrix p=a.pow(ev[e+1]-ev[e]-1);
      p=p*b;
      crt=crt*p;
    }

    printf("Case %d: %lld\n", hoge++,crt[0][W-1]);

  }
  return 0;
}