#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 3005;

int r, c, k, a[sz][sz];
ll dp[sz][sz][4];

ll fnc(int x, int y, int d) {
   if(x == r && y == c) {
      if(d) return a[x][y];
      return 0;
   }
   ll &w = dp[x][y][d];
   if(w < 0) {
      w = 0;
      if(y < c) w = max(w, fnc(x, y+1, d));
      if(x < r) w = max(w, fnc(x+1, y, 3));
      if(d && a[x][y]) {
         if(y < c) w = max(w, a[x][y] + fnc(x, y+1, d-1));
         if(x < r) w = max(w, a[x][y] + fnc(x+1, y, 3));
      }
   }
   return w;
}

int main() {
   cin >> r >> c >> k;
   while(k--) {
      int x, y, v;
      scanf("%d %d %d", &x, &y, &v);
      a[x][y] = v;
   }
   memset(dp, -1, sizeof(dp));
   cout << fnc(1, 1, 3) << endl;
}
