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<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
#include<iostream>
#define N 75
#define eps 1e-6
#define ll long long
#define db double
#define inf 0x3fffffff
#define A(a) printf("a==%d",a);
#define CC(x,y) memset(x,y,sizeof(x))
#define lson l,mid,rt<<1
#define rson mid+1,r,(rt<<1)+1
#define M 1000000009
using namespace std;
struct node
{
    ll a[77][77];
} a,b,c,d,e;
int i,j,k,m,n,x,y,z;
ll h;
struct node2
{
    ll x,y;
}f[50];
node mul(node a,node b)
{
    CC(d.a,0);
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
          for (int k=0;k<n;k++)
    {
          d.a[i][j]=(d.a[i][j]+a.a[i][k]*b.a[k][j])%M;
    }
    return d;
}
node work(ll x)
{
    c=b;
    CC(e.a,0);
    for (i=0;i<n;i++) e.a[i][i]=1;
    while (x)
    {
        if (x&1)e=mul(e,c);
        c=mul(c,c);
        x=x>>1;
    }
    return e;
}
bool cmp(node2 a,node2 b)
{
    return a.y<b.y;
}
int main()
{
    //freopen("in.txt","r",stdin);
    int cas=1;
    while (scanf("%d%lld%d",&n,&h,&z),n)
    {
        CC(a.a,0);CC(b.a,0);
        a.a[0][0]=1;
        for (i=0; i<n; i++)
            for (j=0; j<n; j++)
                if ((abs(j-i))<=1) b.a[i][j]=1;
        c=b;
        CC(f,0);
        f[0].y=1;
        for (i=1;i<=z;i++)
            scanf("%lld%lld",&f[i].x,&f[i].y);
        f[z+1].y=h;f[z+1].x=-1;
        sort(f,f+z+2,cmp);
        for (int i=1;i<=z+1;i++)
        {
            ll x=f[i].y-f[i-1].y;
            e=work(x);
            a=mul(a,e);
            if (f[i].x!=-1) a.a[0][f[i].x-1]=0;
        }
        printf("Case %d: %lld\n",cas++,a.a[0][n-1]);
    }
    return 0;
}