package main import . "fmt" func main() { var h,w,k int Scan(&h,&w,&k) f:=make([][]int64,h+1) for x:=range f { f[x]=make([]int64,w+1) } for ;k>0;k-- { var x,y int var v int64 Scan(&x,&y,&v) f[x][y]=v } var a int64 const m=998244353 for i:=1;i<=h;i++ { for j:=1;j<=w;j++ { for x:=1;x<=h;x++ { for y:=1;y<=w;y++ { if x+y>=i+j&&x-y>=i-j { a=(a+f[x][y])%m } } } } } Println(a) }