#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 998244353;
struct matrix {
int n = 0, m = 0;
int a[5][5] = {};
void print() {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
printf("%d ", a[i][j]);
}
printf("\n");
}
printf("\n");
}
};
matrix mul(matrix a, matrix b) {
matrix res;
res.n = a.n;
res.m = b.m;
for (int i = 1; i <= a.n; i++) {
for (int j = 1; j <= a.m; j++) {
for (int k = 1; k <= b.m; k++) {
res.a[i][k] = (res.a[i][k] + 1ll * a.a[i][j] * b.a[j][k] % mod) % mod;
}
}
}
return res;
}
matrix unit(int n) {
matrix res;
res.n = res.m = n;
for (int i = 1; i <= n; i++) {
res.a[i][i] = 1;
}
return res;
}
matrix pow(matrix a, long long p) {
matrix res = unit(a.n);
for (; p; p >>= 1, a = mul(a, a)) {
if (p & 1) {
res = mul(res, a);
}
}
return res;
}
struct segmenttree {
matrix a[400010];
matrix nodes[800010];
void pushup(int p) {
nodes[p] = mul(nodes[p << 1], nodes[p << 1 | 1]);
}
void build(int p, int l, int r) {
if (l == r) {
nodes[p] = a[l];
return;
}
int mid = (l + r) >> 1;
build(p << 1, l, mid);
build(p << 1 | 1, mid + 1, r);
pushup(p);
}
void modify(int p, int l, int r, int k, matrix x) {
if (l == r) {
nodes[p] = x;
return;
}
int mid = (l + r) >> 1;
if (k <= mid) {
modify(p << 1, l, mid, k, x);
} else {
modify(p << 1 | 1, mid + 1, r, k, x);
}
pushup(p);
}
} sgt;
matrix base;
int n, m, q, x[100010], y[100010], t[100010];
bool is[200010][5];
matrix make(int k) {
matrix res;
res.n = res.m = n;
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j++) {
if (is[k][j]) break;
if (i - j == 1 || j - i == 1) {
res.a[i][j] = res.a[j][i] = 1;
}
}
}
return res;
}
int main() {
scanf("%d%d%d", &n, &m, &q);
base = make(0);
for (int i = 1; i <= q; i++) {
scanf("%d%d", &x[i], &y[i]);
t[i] = y[i];
}
sort(t + 1, t + q + 1);
int uq = unique(t + 1, t + q + 1) - t - 1;
for (int i = 1; i <= uq; i++) {
sgt.a[2 * i - 1] = pow(base, t[i] - t[i - 1] - 1);
sgt.a[2 * i] = base;
}
sgt.a[2 * uq + 1] = pow(base, m - t[uq]);
int sgtn = 2 * uq + 1;
// for (int i = 1; i <= sgtn; i++) {
// sgt.a[i].print();
// }
sgt.build(1, 1, sgtn);
// sgt.nodes[1].print();
for (int i = 1; i <= q; i++) {
int k = lower_bound(t + 1, t + uq + 1, y[i]) - t;
is[k][x[i]] = true;
sgt.a[2 * k] = make(k);
// printf("===== %d =====\n", i);
// for (int j = 1; j <= sgtn; j++) {
// sgt.a[j].print();
// }
// printf("===== %d =====\n", i);
// printf("then the ans is :\n");
sgt.modify(1, 1, sgtn, 2 * k, make(k));
// sgt.nodes[1].print();
// printf("===== %d =====\n\n\n\n", i);
printf("%d\n", sgt.nodes[1].a[1][n]);
}
return 0;
}