H, W, K = map(int, input().split()) ans = 0 mod = 998244353 def calc(x, y): ret = 0 if x <= y: ret += x * (x + 1) // 2 else: ret += (x * (x + 1) // 2 - (x - y) * (x - y + 1) // 2) if x <= W - y + 1: ret += x * (x + 1) // 2 else: ret += (x * (x + 1) // 2 - (x - (W - y + 1)) * (x - (W - y + 1) + 1) // 2) ret -= x return ret for i in range(K): x, y, v = map(int, input().split()) C = calc(x, y) % mod ans = (ans + C * v) % mod print(ans)