h,w,k = map(int,input().split()) xyv = {} for _ in range(k): x,y,v = map(int,input().split()) xyv[(x-1,y-1)] = v c = [[0]*w for _ in range(h)] 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: c[x][y] += 1 ans = 0 for x in range(h): for y in range(w): if (x,y) in xyv: ans += xyv[(x,y)]*c[x][y] print(ans%998244353)