using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    int R, C;
    int K;
    public void Solve()
    {
        var sc = new Scanner();
        R = sc.NextInt();
        C = sc.NextInt();
        K = sc.NextInt();

        long[,] V = new long[R, C];
        for (int i = 0; i < K; i++)
        {
            int r = sc.NextInt() - 1;
            int c = sc.NextInt() - 1;
            int v = sc.NextInt();
            V[r, c] = v;
        }

        var dp = new long[R, C, 4];
        for (int i = 0; i < R; i++)
        {
            for (int j = 0; j < C; j++)
            {
                for (int k = 0; k <= 3; k++)
                {
                    dp[i, j, k] = long.MinValue;
                }
            }
        }
        dp[0, 0, 0] = 0;
        dp[0, 0, 1] = V[0, 0];
        for (int i = 0; i < R; i++)
        {
            for (int j = 0; j < C; j++)
            {
                for (int k = 0; k <= 3; k++)
                {
                    // 下から
                    if (i - 1 >= 0)
                    {
                        dp[i, j, 1] = Math.Max(dp[i, j, 1], dp[i - 1, j, k] + V[i, j]);
                        dp[i, j, 0] = Math.Max(dp[i, j, 0], dp[i - 1, j, k]);
                    }

                    if (j - 1 >= 0)
                    {
                        if (k - 1 >= 0) dp[i, j, k] = Math.Max(dp[i, j, k], dp[i, j - 1, k - 1] + V[i, j]);
                        dp[i, j, k] = Math.Max(dp[i, j, k], dp[i, j - 1, k]);
                    }
                }
            }
        }

        long ans = 0;
        for (int i = 0; i <= 3; i++)
        {

            ans = Math.Max(ans, dp[R - 1, C - 1, i]);
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 392252