#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=998244353; ll mod_pow(ll x,ll y,ll mod){ ll res=1; while(y>0){ if(y&1){ res*=x; res%=mod; } x*=x; x%=mod; y/=2; } return res; } int main(){ int H,W,K; cin>>H>>W>>K; vector x(K),y(K); vector v(K); for(int k=0;k>x[k]>>y[k]>>v[k]; } ll inv2=mod_pow(2,MOD-2,MOD); auto cumsum=[&](ll n){ //1+2+3+...+n ll res=n%MOD; res*=(n+1)%MOD; res%=MOD; res*=inv2; res%=MOD; return res; }; //[l,r] auto cumdif=[&](ll l,ll r){ ll res=cumsum(r); if(l>=1){ res-=cumsum(l-1); res+=MOD; res%=MOD; } return res; }; //タカラが(px,py)にある auto f=[&](ll px,ll py){ ll t=px+py; ll u=px-py; ll lb=max(1LL,1-u); ll c1=cumdif(lb,py);//[lb,py] c1+=u*(py-lb+1)%MOD; c1%=MOD; ll ub=min(1LL*W,t-1); //cout<<"ub="<