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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

ll dp[3010][3010][4];
ll cell[3010][3010];

void solve() {
    ll R, C, K;
    cin >> R >> C >> K;
    for (ll i = 0; i < K; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        cell[a][b] = c;
    }

    for (ll i = 0; i <= R; i++) {
        for (ll j = 0; j <= C; j++) {
            for (ll k = 0; k <= 3; k++) {
                dp[i][j][k] = -L_INF;
            }
        }
    }
    dp[0][1][0] = dp[1][0][0] = 0;

    for (ll i = 1; i <= R; i++) {
        for (ll j = 1; j <= C; j++) {
            for (ll k = 0; k <= 3; k++) {
                dp[i][j][k] = dp[i][j - 1][k];
                if (k == 0) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][0]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][1]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][2]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][3]);
                }
                if (cell[i - 1][j - 1] > 0 && k == 1) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][0] + cell[i - 1][j - 1]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][1] + cell[i - 1][j - 1]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][2] + cell[i - 1][j - 1]);
                    dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][3] + cell[i - 1][j - 1]);
                }
                if (cell[i - 1][j - 1] > 0 && k > 0) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + cell[i - 1][j - 1]);
                }
            }
        }
    }

    ll ans = 0;
    for (ll i = 0; i <= 3; i++) {
        ans = max(ans, dp[R][C][i]);
    }
    prints()(ans);

    // for (ll k = 0; k <= 3; k++) {
    //     for (ll i = 0; i <= R; i++) {
    //         for (ll j = 0; j <= C; j++) {
    //             cout << dp[i][j][k] << " ";
    //         }
    //         cout << "\n";
    //     }
    //     cout << "\n";
    // }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 356356