// 提出時にassertはオフ
#ifndef DEBUG
#ifndef NDEBUG
#define NDEBUG
#endif
#endif

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;

#define ALL(x) (x).begin(), (x).end()
template <class T> using vec = vector<T>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H, W, K;
    cin >> H >> W >> K;
    mint ans = 0;
    for(ll i = 0; i < K; i++){
        ll x, y, v;
        cin >> x >> y >> v;
        mint cnt = 0;
        cnt += x;
        ll abs_1 = x - min(y - 1, W - y);
        if(abs_1 <= 1){
            // x-1~1の和 * 2
            cnt += x * (x - 1);
        } else {
            // x-1~abs_1の和 * 2 + (abs_1 - 1 ~ abs_2の和)
            ll abs_2 = max((ll)1, x - max(y - 1, W - y));
            cnt += (x - 1 + abs_1) * (x - 1 - abs_1 + 1);
            cnt += (abs_1 - 1 + abs_2) * (abs_1 - 1 - abs_2 + 1) / 2;
        }
        ans += cnt * v;
    }
    cout << ans.val() << "\n";
}