h, w, k = map(int, input().split()) w2 = 2 * w d = [[0] * w2 for _ in range(h)] for _ in range(k): x, y, v = map(int, input().split()) d[x-1][w + y-1] = v for i in range(1, h)[::-1]: for j in range(1, w2)[::-1]: d[i-1][j-1] += d[i][j] for i in range(1, h)[::-1]: for j in range(w2 - 1): d[i-1][j+1] += d[i][j] ans = 0 for i in range(h): for j in range(w): ans += d[i][w + j] if i + 1 < h: ans += d[i+1][w + j] ans %= 998244353 print(ans % 998244353)