#include<bits/stdc++.h>
using namespace std;

#define NIL -1000000000

struct xyz {
  int x,y,z;
  bool operator<(const xyz& a) const {
    return z > a.z;
  }
};

int G[51][51];
bool F[51][51],used[51][51];
int w,d,n;
int dx[]={1,0,0,-1},dy[]={0,1,-1,0};

bool bfs(xyz s) {
  G[s.x][s.y]=s.z;
  queue<xyz> q;
  q.push(s);
  while(!q.empty()) {
    xyz v=q.front(); q.pop();
    used[v.x][v.y]=true;
    for(int i=0;i<4;++i) {
      int nx=v.x+dx[i],ny=v.y+dy[i];
      if(nx<=0||ny<=0||nx>w||ny>d) continue;
      if(used[nx][ny]) continue;
      if(F[nx][ny]) {
        if(abs(G[nx][ny]-v.z)>=2) return false;
        else continue;
      }
      if(G[nx][ny]>v.z+1) return false;
      else if(G[nx][ny]>=v.z-1) continue;
      else G[nx][ny]=v.z-1;
      q.push({nx,ny,G[nx][ny]});
      //cout << G[nx][ny] << endl;
    }
  }
  return true;
}

signed main() {
  cin >> w >> d >> n;
  for(int i=1;i<=w;++i)
    for(int j=1;j<=d;++j)
      G[i][j]=NIL;
  vector<xyz> in(n);
  for(auto&a:in) cin >> a.x >> a.y >> a.z;
  sort(in.begin(),in.end());
  for(int i=0;i<n;++i) {
    memset(used,false,sizeof(used));
    F[in[i].x][in[i].y]=true;
    if(!bfs(in[i])) {
      cout << "No" << endl;
      //break;
      return 0;
    }
  }

  int ans=0;
  for(int i=1;i<=w;++i)
    for(int j=1;j<=d;++j)
      ans+=G[i][j];
  cout << ans << endl;

  /*
  cout << endl;
  for(int j=1;j<=d;++j) {
    for(int i=1;i<=w;++i) {
      cout << G[i][j] << " ";
    }
    cout << endl;
  }
  */


  return 0;
}

