#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int h,w,k;cin>>h>>w>>k;
    int a[h+1][w+1];
    for(int i=0;i<=h;++i) for(int j=0;j<=w;++j) a[i][j]=0;
    for(int i=0;i<k;++i)
    {
        int x,y,v;cin>>x>>y>>v;
        a[x][y]+=v;
    }
    int ans=0;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            for(int x=0;x<=h;++x)
            {
                for(int y=0;y<=w;++y)
                {
                    if(x+y>=i+j && x-y>=i-j)
                    {
                        ans+=a[x][y];ans%=p;
                    }
                }
            }
        }
    }
    cout<<ans;
    return 0;
}