#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

template <long long MOD> struct Fp {
    long long v;
    constexpr Fp(long long v = 0) noexcept: v(v % MOD) {
        if (v < 0) v += MOD;
    }
    constexpr long long getMod() const { return MOD; }
    constexpr long long value() const { return v; }
    constexpr Fp operator - () const noexcept { return v ? MOD - v : 0; }
    constexpr Fp operator + (const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp operator += (const Fp &r) noexcept {
        v += r.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp &r) noexcept {
        v -= r.v;
        if (v < 0) v += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp &r) noexcept {
        v = v * r.v % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp &r) noexcept {
        long long a = r.v, b = MOD, x = 1, y = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(x -= t * y, y);
        }
        v = v * x % MOD;
        if (v < 0) v += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp &r) const noexcept { return this->v == r.v; }
    constexpr bool operator != (const Fp &r) const noexcept { return this->v != r.v; }
    friend constexpr ostream &operator << (ostream &os, const Fp<MOD> &x) noexcept { return os << x.v; }
    friend constexpr istream &operator >> (istream &is, Fp<MOD> &x) noexcept { return is >> x.v; }
    Fp<MOD> pow(long long n) noexcept {
        Fp<MOD> res(1), tmp(v);
        while (n > 0) {
            if (n & 1) res *= tmp;
            tmp *= tmp;
            n >>= 1;
        }
        return res;
    }
};
using mint = Fp<1000000009>;

// template <class T, size_t N> class SquareMatrix {
// public:
//     array<array<T, N>, N> v;
    
//     SquareMatrix() {
//         for (size_t i = 0; i < N; ++i)
//             for (size_t j = 0; j < N; ++j)
//                 v[i][j] = T(0);
//     }
    
//     void init(T x) { v.fill(v.begin(), v.end(), x); }
//     size_t height() const { return N; }
//     size_t width() const { return N; }
//     inline const array<T, N>& operator [] (size_t i) const { return v[i]; }
//     inline array<T, N>& operator [] (size_t i) { return v[i]; }
//     friend ostream& operator << (ostream &os, SquareMatrix<T, N> M) {
//         for (int i = 0; i < M.height(); ++i) {
//             os << '|';
//             for (int j = 0; j < M.width(); ++j)
//                 os << ' ' << M[i][j];
//             os << " |\n";
//         }
//         return os;
//     }
// };

// template <class T, size_t N> SquareMatrix<T, N> operator + (const SquareMatrix<T, N>& A, const SquareMatrix<T, N>& B) {
//     SquareMatrix<T, N> C;
//     for (int i = 0; i < N; ++i)
//         for (int j = 0; j < N; ++j)
//             C[i][j] = A[i][j] + B[i][j];
//     return C;
// }

// template <class T, size_t N> SquareMatrix<T, N> operator - (const SquareMatrix<T, N>& A, const SquareMatrix<T, N>& B) {
//     SquareMatrix<T, N> C;
//     for (int i = 0; i < N; ++i)
//         for (int j = 0; j < N; ++j)
//             C[i][j] = A[i][j] - B[i][j];
//     return C;
// }

// template <class T, size_t N> SquareMatrix<T, N> operator * (const SquareMatrix<T, N>& A, const SquareMatrix<T, N>& B) {
//     SquareMatrix<T, N> res;
//     for (size_t i = 0; i < N; ++i)
//         for (size_t j = 0; j < N; ++j)
//             for (size_t k = 0; k < N; ++k)
//                 res[i][j] += A[i][k] * B[k][j];
//     return res;
// }

// template <class T, size_t N> vector<T> operator * (const SquareMatrix<T, N>& A, const vector<T>& v) {
//     vector<T> u(N, 0);
//     for (int i = 0; i < N; ++i)
//         for (int j = 0; j < N; ++j)
//             u[i] = u[i] + A[i][j] * v[j];
//     return u;
// }

// template <class T, size_t N> SquareMatrix<T, N> pow(SquareMatrix<T, N> A, long long n) {
//     SquareMatrix<T, N> B;
//     for (int i = 0; i < N; ++i) B[i][i] = 1;
//     while (n > 0) {
//         if (n & 1) B = B * A;
//         A = A * A;
//         n >>= 1;
//     }
//     return B;
// }

template <class T> class Matrix {
public:
    int n, m;
    vector<vector<T>> v;
    
    Matrix(int n, int m) : n(n), m(m), v(n, vector<T>(m, 0)) {}
    Matrix(int n, int m, T x) : n(n), m(m), v(n, vector<T>(m, x)) {}
    
    void init(T x) { v.clear(); v.resize(n, vector<T>(m, x)); }
    int height() const { return n; }
    int width() const { return m; }
    inline const vector<T>& operator [] (int i) const { return (v.at(i)); }
    inline vector<T>& operator [] (int i) { return (v.at(i)); }
    friend ostream& operator << (ostream &os, Matrix<T> M) {
        for (int i = 0; i < M.height(); ++i) {
            os << '|';
            for (int j = 0; j < M.width(); ++j)
                os << ' ' << M[i][j];
            os << " |\n";
        }
        return os;
    }
};

template <class T> Matrix<T> operator + (const Matrix<T>& A, const Matrix<T>& B) {
    const int n = A.height(), m = A.width();
    Matrix<T> C(n, m);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            C[i][j] = A[i][j] + B[i][j];
    return C;
}

template <class T> Matrix<T> operator - (const Matrix<T>& A, const Matrix<T>& B) {
    const int n = A.height(), m = A.width();
    Matrix<T> C(n, m);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            C[i][j] = A[i][j] - B[i][j];
    return C;
}

template <class T> Matrix<T> operator * (const Matrix<T>& A, const Matrix<T>& B) {
    const int n = A.height(), m = A.width(), l = B.height();
    assert(m == l);
    Matrix<T> C(n, m, 0);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            for (int k = 0; k < l; ++k)
                C[i][j] = C[i][j] + A[i][k] * B[k][j];
    return C;
}

template <class T> vector<T> operator * (const Matrix<T>& A, const vector<T>& v) {
    vector<T> u(A.width(), 0);
    for (int i = 0; i < A.height(); ++i)
        for (int j = 0; j < A.width(); ++j)
            u[i] = u[i] + A[i][j] * v[j];
    return u;
}

template <class T> Matrix<T> pow(Matrix<T> A, long long n) {
    assert(A.height() == A.width());
    Matrix<T> B(A.height(), A.height(), 0);
    for (int i = 0; i < A.height(); ++i) B[i][i] = 1;
    while (n > 0) {
        if (n & 1) B = B * A;
        A = A * A;
        n >>= 1;
    }
    return B;
}

int W, H, N;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
    while (scanf("%lld%lld%lld", &W, &H, &N), W) {
        vector<pair<int, int>> ps;
        REP (i, N) {
            int x, y;
            scanf("%lld%lld", &x, &y);
            x--; y--;
            ps.emplace_back(y, x);
        }
        ps.emplace_back(H - 1, W);
        sort(ps.begin(), ps.end());

        Matrix<mint> A(W, W), B(W, W);
        for (int i = 0; i < W; ++i) {
            if (i - 1 >= 0) A[i][i - 1] = 1;
            A[i][i] = 1;
            if (i + 1 < W) A[i][i + 1] = 1;
        }
        vector<mint> X(W, 0);
        X[0] = 1;
        int lastY = 0;
        int l = 0, r = 0;
        while (l < ps.size()) {
            while (r < ps.size() && ps[r].first == ps[l].first) r++;
            B = pow(A, ps[l].first - lastY);
            vector<mint> newX(W, 0);
            for (int i = 0; i < W; ++i) {
                for (int j = 0; j < W; ++j) {
                    newX[i] += B[i][j] * X[j];
                }
            }
            lastY = ps[l].first;
            while (l < r) {
                if (ps[l].second < W) newX[ps[l].second] = 0;
                l++;
            }
            X = newX;
        }
        printf("Case %lld: %lld\n", t, X[W - 1]);
        t++;
    }
}


Measured memory_bytes: 3280