H,W,K=map(int,input().split()) mod=998244353 ANS=0 for i in range(K): x,y,v=map(int,input().split()) ANS+=x*v r=W-y if r