# 制約が大きければ寄与度か # まずナイーブにやってみる # H, W <50なので4重ループでも問題ないはず mod = 998244353 H, W, K = map(int, input().split()) grid = [[0]*W for i in range(H)] for i in range(K): x, y, v = map(int, input().split()) grid[x-1][y-1] = v calc = 0 for i in range(H): for j in range(W): subcalc = 0 for x in range(H): for y in range(W): if x+y >= i+j and x-y >= i-j: subcalc += grid[x][y] subcalc %= mod calc += subcalc calc %= mod print(calc%mod)