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>
template<typename T>
using matrix = std::vector<std::vector<T>>;
const int mod = 1e9 + 9;
template<typename T>
matrix<T> modmul(const matrix<T> &A, const matrix<T> &B) {
  matrix<T> res((int)(A.size()), std::vector<T>((int)(B[0].size())));
  for(int i=0;i<(int)(A.size());++i) {
    for(int j=0;j<(int)(B.size());++j) {
      for(int k=0;k<(int)(B[0].size());++k) {
        res[i][k] += A[i][j] * B[j][k] % mod;
        res[i][k] %= mod;
      }
    }
  }
  return res;
}
template<typename T>
std::vector<T> modmul(const matrix<T> &A, const std::vector<T> &v) {
  std::vector<T> res((int)(A.size()));
  for(int i=0;i<(int)(A.size());++i) {
    for(int j=0;j<(int)(v.size());++j) {
      res[i] += A[i][j] * v[j] % mod;
      res[i] %= mod;
    }
  }
  return res;
}
template<typename T>
matrix<T> E(const int n) {
  matrix<T> res(n, std::vector<T>(n));
  for(int i=0;i<n;++i) {
    res[i][i] = 1;
  }
  return res;
}
template<typename T>
matrix<T> modpow(matrix<T> A, long long k) {
  auto res = E<T>((int)(A.size()));
  while(k) {
    if(k&1) res = modmul(res, A);
    A = modmul(A, A);
    k >>= 1;
  }
  return res;
}
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000009;
const ll INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(ll i=0;i<(ll)(s.size());++i) {
    cout << s[i];
    if(i == (ll)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
bool solve(ll cnt) {
  ll w, h, n; cin >> w >> h >> n;
  if(w == 0) return false;
  map<ll, vector<ll>> mp;
  for(ll i=0;i<n;++i) {
    ll x, y; cin >> x >> y;
    x--; y--;
    mp[y].push_back(x);
  }
  matrix<ll> A(w, vll(w));
  for(ll i=0;i<w;++i) {
    for(ll j=0;j<w;++j) {
      if(abs(i-j) <= 1) A[i][j] = 1;
    }
  }
  vector<ll> v(w);
  v[0] = 1;
  ll prevh = 0;
  for(auto &e: mp) {
    if(e.first == 0) continue;
    matrix<ll> tmp = A;
    tmp = modpow(tmp, e.first - prevh);
    v = modmul(tmp, v);
    for(auto &e2: e.second) {
      v[e2] = 0;
    }
    prevh = e.first;
  }
  if(prevh != h-1) {
    A = modpow(A, h-1 - prevh);
    v = modmul(A, v);
  }
  cout << "Case " << cnt << ": " << v[w-1] << endl;
  return true;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll cnt = 0;
  while(1) {
    cnt++;
    if(!solve(cnt)) break;
  }
}