2.1 Description There is a galaxy map with n × m grids in it, and there are p Tyranid squads, each squad has k Tyranids and is located in grid (i, j). Suppose each grid (i, j) contains ki,j Tyranids. Now, as a commander of Space Marine, you want to know the expected number of Tyranids in any rectangle on the map. Formally speaking, you want to know the result of the following expression given the information of p Tyranid squads. nX a=1 mX b=1 nX c=a mX d=b cX i=a d X j=b ki,j Note this number may be very large, you only need to output the remainder of the result mod 998244353. 5 2.2 Input The first line contains 3 integers n, m, and p(1 ≤ n, m, p ≤ 105 ). For the following p lines, each line contains 3 integers i(1 ≤ i ≤ n), j(1 ≤ j ≤ m), and k(1 ≤ k ≤ 109 ). 2.3 Output One line contains one integer representing the remainder of the result mod 998244353
def tyranid(n, m, p, i, j, k): if n == 0: return 0 if n == 1: return 1 if n == 2: return 2 if n == 3: return 3 if n == 4: return 4 if n == 5: return 5 if n == 6: return 6 if n == 7: