h, w, k = map(int, input().split()) t = [[0 for _ in range(w)] for _ in range(h)] for i in range(k): x, y, v = map(int, input().split()) t[x-1][y-1] = v ans = [] for i in range(h): for j in range(w): tmp = 0 for x in range(h): for y in range(w): if x + y >= i + j and x - y >= i - j: tmp += t[x][y] ans.append(tmp) print(sum(ans)%998244353)