Language: C++

#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;

typedef ll number;
const ll MOD = 1000000007;
typedef vector<number> array;
typedef vector<array> matrix;
matrix ident(ll n) {
	matrix A(n, array(n));
	for (int i = 0; i < n; ++i) A[i][i] = 1;
	return A;
}
// O( n^2 )
array mul(const matrix &A, const array &x) {
	array y(A.size());
	for (int i = 0; i < A.size(); ++i)
		for (int j = 0; j < A[0].size(); ++j) {
			y[i] += A[i][j] * x[j];
			//y[i] %= MOD;
		}

	return y;
}
// O( n^3 )
matrix mul(const matrix &A, const matrix &B) {
	matrix C(A.size(), array(B[0].size()));
	for (int i = 0; i < C.size(); ++i)
		for (int j = 0; j < C[i].size(); ++j)
			for (int k = 0; k < A[i].size(); ++k) {
				C[i][j] += A[i][k] * B[k][j];
				//C[i][j] %= MOD;
			}
	return C;
}
// O( n^3 log e )
matrix pow(const matrix &A, ll e) {
	return e == 0 ? ident(A.size()) :
		e % 2 == 0 ? pow(mul(A, A), e / 2) : mul(A, pow(A, e - 1));
}


int main() {
	ll W,H,N;
	ll count = 0;
	while(cin >> W >> H >> N, W!=0){
		count++;
		array M(W);
		M[0] = 1;
		matrix Po(W, array(W));
		for(int y=0;y<W;y++)
			for(int x=0;x<W;x++)
				Po[y][x] = abs(y-x)<=1;

		vector<P> ob(N);
		for(int i=0;i<N;i++){
			ll x, y;
			cin >> x >> y;
			x--; y--;
			ob[i] = P(y, x);
		}
		sort(ob.begin(), ob.end());
		ll now = 0;
		for(int i=0;i<ob.size();i++){
			M = mul(pow(Po, ob[i].first - now), M);
			M[ob[i].second] = 0;
			now = ob[i].first;
		}
		M = mul(pow(Po, H - 1 - now), M);
		cout << "Case " << count << ": " << M[W-1] << endl;
	}
	return 0;
}

Compiler output:
a.cc:28:21: error: template argument 1 is invalid
   28 | typedef vector<array> matrix;
      |                     ^
a.cc:28:21: error: template argument 2 is invalid
a.cc: In function 'matrix ident(ll)':
a.cc:30:21: error: reference to 'array' is ambiguous
   30 |         matrix A(n, array(n));
      |                     ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:27:24: note:                 'typedef class std::vector<long long int> array'
   27 | typedef vector<number> array;
      |                        ^~~~~
a.cc:30:29: error: expression list treated as compound expression in initializer [-fpermissive]
   30 |         matrix A(n, array(n));
      |                             ^
a.cc:31:38: error: invalid types 'matrix {aka int}[int]' for array subscript
   31 |         for (int i = 0; i < n; ++i) A[i][i] = 1;
      |                                      ^
a.cc: At global scope:
a.cc:35:1: error: reference to 'array' is ambiguous
   35 | array mul(const matrix &A, const array &x) {
      | ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:27:24: note:                 'typedef class std::vector<long long int> array'
   27 | typedef vector<number> array;
      |                        ^~~~~
a.cc: In function 'matrix mul(const matrix&, const matrix&)':
a.cc:47:20: error: request for member 'size' in 'A', which is of non-class type 'const matrix' {aka 'const int'}
   47 |         matrix C(A.size(), array(B[0].size()));
      |                    ^~~~
a.cc:47:28: error: reference to 'array' is ambiguous
   47 |         matrix C(A.size(), array(B[0].size()));
      |                            ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:27:24: note:                 'typedef class std::vector<long long int> array'
   27 | typedef vector<number> array;
      |                        ^~~~~
a.cc:47:35: error: invalid types 'const matrix {aka const int}[int]' for array subscript
   47 |         matrix C(A.size(), array(B[0].size()));
      |                                   ^
a.cc:47:46: error: expression list treated as compound expression in initializer [-fpermissive]
   47 |         matrix C(A.size(), array(B[0].size()));
      |                                              ^
a.cc:48:31: error: request for member 'size' in 'C', which is of non-class type 'matrix' {aka 'int'}
   48 |         for (int i = 0; i < C.size(); ++i)
      |                               ^~~~
a.cc:49:38: error: invalid types 'matrix {aka int}[int]' for array subscript
   49 |                 for (int j = 0; j < C[i].size(); ++j)
      |                                      ^
a.cc:50:46: error: invalid types 'const matrix {aka const int}[int]' for array subscript
   50 |                         for (int k = 0; k < A[i].size(); ++k) {
      |                                              ^
a.cc:51:34: error: invalid types 'matrix {aka int}[int]' for array subscript
   51 |                                 C[i][j] += A[i][k] * B[k][j];
      |                                  ^
a.cc:51:45: error: invalid types 'const matrix {aka const int}[int]' for array subscript
   51 |                                 C[i][j] += A[i][k] * B[k][j];
      |                                             ^
a.cc:51:55: error: invalid types 'const matrix {aka const int}[int]' for array subscript
   51 |                                 C[i][j] += A[i][k] * B[k][j];
      |                                                       ^
a.cc: In function 'matrix pow(const matrix&, ll)':
a.cc:58:33: error: request for member 'size' in 'A', which is of non-class type 'const matrix' {aka 'const int'}
   58 |         return e == 0 ? ident(A.size()) :
      |                                 ^~~~
a.cc: In function 'int main()':
a.cc:68:17: error: reference to 'array' is ambiguous
   68 |                 array M(W);
      |                 ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:27:24: note:                 'typedef class std::vector<long long int> array'
   27 | typedef vector<number> array;
      |                        ^~~~~
a.cc:69:17: error: 'M' was not declared in this scope
   69 |                 M[0] = 1;
      |                 ^
a.cc:70:30: error: reference to 'array' is ambiguous
   70 |                 matrix Po(W, array(W));
      |                              ^~~~~
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:27:24: note:                 'typedef class std::vector<long long int> array'
   27 | typedef vector<number> array;
      |                        ^~~~~
a.cc:70:38: error: expression list treated as compound expression in initializer [-fpermissive]
   70 |                 matrix Po(W, array(W));
      |                                      ^
a.cc:73:35: error: invalid types 'matrix {aka int}[int]' for array subscript
   73 |                                 Po[y][x] = abs(y-x)<=1;
      |                                   ^