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