#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const int N=3e3+5;
ll a[N][N],dp[N][N][4],n,m;
ll go(ll i,ll j,ll k)
{
    if(i==n+1 || j==m+1)
    {
        return 0;
    }
    else if(dp[i][j][k]!=-1)
    {
        return dp[i][j][k];
    }
    else if(k==3)
    {
        return go(i+1,j,0);
    }
    else
    {
        return dp[i][j][k]=max({go(i+1,j,0)+a[i][j],go(i,j+1,k+1)+a[i][j],go(i,j+1,k)});
    }
}
int main()
{
    ft
    ll t,i,j,k,l,r,p;
    cin>>n>>m>>k;
    memset(a,0,sizeof(a));
    memset(dp,-1,sizeof(dp));
    for(i=0;i<k;i++)
    {
        cin>>l>>r>>p;
        a[l][r]=p;
    }
    cout<<go(1,1,0)<<"\n";
    return 0;
}

