#![allow(dead_code, unused_imports, unused_macros, non_snake_case)] fn main() { let mut input = Input::new(); let H = input.read::(); let W = input.read::(); let K = input.read::(); let mut treasures = vec![vec![0; W]; H]; for _ in 0 .. K { let x = input.read::() - 1; let y = input.read::() - 1; let v = input.read::(); treasures[x][y] = v; } let mut ans = 0; for i0 in 0 .. H { for j0 in 0 .. W { for i in 0 .. H { for j in 0 .. W { if i + j >= i0 + j0 && i + j0 >= i0 + j { ans += treasures[i][j]; ans %= 998244353; } } } } } println!("{}", ans); } type Int = i64; const MOD: Int = 1_000_000_007; const INF: Int = 1_000_000_000; const YESNO: [&'static str; 2] = ["Yes", "No"]; pub struct Input { words: std::collections::VecDeque, } impl Input { pub fn new() -> Self { use std::io::prelude::*; let mut stdin = std::io::stdin(); let mut input = String::new(); stdin.read_to_string(&mut input).unwrap(); let words = input.split_ascii_whitespace().map(str::to_string).collect(); Self { words } } pub fn read(&mut self) -> T { let res = self.words.pop_front().unwrap().parse(); if let Ok(r) = res { r } else { panic!("read() failed") } } } fn yes() { println!("{}", YESNO[0]); } fn no() { println!("{}", YESNO[1]); } fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }