h,w,k = map(int,input().split()) ans = 0 mod =998244353 now = 1 xx = [0] for i in range(2*10**5): xx.append(xx[-1] + now) now += 2 now %= mod for i in range(k): x,y,v = map(int,input().split()) cnt = xx[x] lcnt = max(0,x-y) rcnt = max(0, x-(w-y+1)) cnt -= lcnt*(lcnt+1)//2 + rcnt*(rcnt+1)//2 cnt %= mod ans += v * cnt ans %= mod print(ans)