import sys

input = sys.stdin.buffer.readline
r, c, k = map(int, input().split())


graph = [[0] * (c) for _ in range(r)]

for _ in range(k):
    d, e, f = map(int, input().split())
    graph[d - 1][e - 1] = f


infi = 10 ** 10
money = [[[-infi] * (c) for _ in range(r)] for _ in range(4)]
money[0][0][0] = 0
for i in range(r):
    for j in range(c):
        for t in range(4):
            m = money[t][i][j]
            delta = graph[i][j]
            if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

            if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

ans = 0
if graph[r - 1][c - 1] > 0:
    for t in range(3):
        money[t][r - 1][c - 1] += graph[r - 1][c - 1]
for i in range(4):
    ans = max(money[i][r - 1][c - 1], ans)

print(ans) import sys sys input = sys.stdin.buffer.readline input sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline r, c, k = map(int, input().split()) r map(int, input().split()) map int input().split() ().split () input split c k [0] * (c) for _ in range(r) for _ in range(r) _ range(r) range r for _ in range(r) [0] * (c) [0] 0 c graph = [[0] * (c) for _ in range(r)] graph [[0] * (c) for _ in range(r)] for _ in range(k):
    d, e, f = map(int, input().split())
    graph[d - 1][e - 1] = f _ range(k) range k d, e, f = map(int, input().split()) d map(int, input().split()) map int input().split() ().split () input split e f graph[d - 1][e - 1] = f graph[d - 1][e - 1] [d - 1] graph d - 1 d 1 e - 1 e 1 f infi = 10 ** 10 infi 10 ** 10 10 10 [[-infi] * (c) for _ in range(r)] for _ in range(4) for _ in range(4) _ range(4) range 4 for _ in range(4) [[-infi] * (c) for _ in range(r)] money = [[[-infi] * (c) for _ in range(r)] for _ in range(4)] money [[[-infi] * (c) for _ in range(r)] for _ in range(4)] money[0][0][0] = 0 money[0][0][0] [0] [0] money 0 0 0 0 for i in range(r):
    for j in range(c):
        for t in range(4):
            m = money[t][i][j]
            delta = graph[i][j]
            if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

            if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) i range(r) range r for j in range(c):
        for t in range(4):
            m = money[t][i][j]
            delta = graph[i][j]
            if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

            if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) j range(c) range c for t in range(4):
            m = money[t][i][j]
            delta = graph[i][j]
            if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

            if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) t range(4) range 4 m = money[t][i][j] m money[t][i][j] [i] [t] money t i j delta = graph[i][j] delta graph[i][j] [i] graph i j if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

             i < r - 1 i r - 1 r 1 ni = i + 1 ni i + 1 i 1 nj = j nj j nt = 0 nt 0 money[nt][ni][nj] = max(money[nt][ni][nj], m) money[nt][ni][nj] [ni] [nt] money nt ni nj max(money[nt][ni][nj], m) max money[nt][ni][nj] [ni] [nt] money nt ni nj m if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

             t < 3 t 3 money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) money[nt][ni][nj] [ni] [nt] money nt ni nj max(money[nt][ni][nj], m + delta) max money[nt][ni][nj] [ni] [nt] money nt ni nj m + delta m delta if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) j < c - 1 j c - 1 c 1 ni = i ni i nj = j + 1 nj j + 1 j 1 nt = t nt t money[nt][ni][nj] = max(money[nt][ni][nj], m) money[nt][ni][nj] [ni] [nt] money nt ni nj max(money[nt][ni][nj], m) max money[nt][ni][nj] [ni] [nt] money nt ni nj m if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) t < 3 t 3 nt = t + 1 nt t + 1 t 1 money[nt][ni][nj] = max(money[nt][ni][nj], m + delta) money[nt][ni][nj] [ni] [nt] money nt ni nj max(money[nt][ni][nj], m + delta) max money[nt][ni][nj] [ni] [nt] money nt ni nj m + delta m delta ans = 0 ans 0 if graph[r - 1][c - 1] > 0:
    for t in range(3):
        money[t][r - 1][c - 1] += graph[r - 1][c - 1] graph[r - 1][c - 1] > 0 graph[r - 1][c - 1] [r - 1] graph r - 1 r 1 c - 1 c 1 0 for t in range(3):
        money[t][r - 1][c - 1] += graph[r - 1][c - 1] t range(3) range 3 money[t][r - 1][c - 1] += graph[r - 1][c - 1] money[t][r - 1][c - 1] [r - 1] [t] money t r - 1 r 1 c - 1 c 1 graph[r - 1][c - 1] [r - 1] graph r - 1 r 1 c - 1 c 1 for i in range(4):
    ans = max(money[i][r - 1][c - 1], ans) i range(4) range 4 ans = max(money[i][r - 1][c - 1], ans) ans max(money[i][r - 1][c - 1], ans) max money[i][r - 1][c - 1] [r - 1] [i] money i r - 1 r 1 c - 1 c 1 ans print(ans) print ans ans = max(money[i][r - 1][c - 1], ans) max(money[i][r - 1][c - 1], ans) ans f = map(int, input().split()) map(int, input().split()) f d, e, f = map(int, input().split()) map(int, input().split()) d nj = j + 1 j + 1 nj ans = 0 0 ans infi = 10 ** 10 10 ** 10 infi r, c, k = map(int, input().split()) map(int, input().split()) r k = map(int, input().split()) map(int, input().split()) k nt = t t nt input = sys.stdin.buffer.readline sys.stdin.buffer.readline input ni = i i ni nt = t + 1 t + 1 nt nj = j j nj nt = 0 0 nt c, k = map(int, input().split()) map(int, input().split()) c e, f = map(int, input().split()) map(int, input().split()) e ni = i + 1 i + 1 ni money = [[[-infi] * (c) for _ in range(r)] for _ in range(4)] [[[-infi] * (c) for _ in range(r)] for _ in range(4)] money m = money[t][i][j] money[t][i][j] m graph = [[0] * (c) for _ in range(r)] [[0] * (c) for _ in range(r)] graph delta = graph[i][j] graph[i][j] delta
import sys

input = sys.stdin.buffer.readline
r, c, k = map(int, input().split())


graph = [[0] * (c) for _ in range(r)]

for _ in range(k):
    d, e, f = map(int, input().split())
    graph[d - 1][e - 1] = f


infi = 10 ** 10
money = [[[-infi] * (c) for _ in range(r)] for _ in range(4)]
money[0][0][0] = 0
for i in range(r):
    for j in range(c):
        for t in range(4):
            m = money[t][i][j]
            delta = graph[i][j]
            if i < r - 1:
                ni = i + 1
                nj = j
                nt = 0
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

            if j < c - 1:
                ni = i
                nj = j + 1
                nt = t
                money[nt][ni][nj] = max(money[nt][ni][nj], m)
                if t < 3:
                    nt = t + 1
                    money[nt][ni][nj] = max(money[nt][ni][nj], m + delta)

ans = 0
if graph[r - 1][c - 1] > 0:
    for t in range(3):
        money[t][r - 1][c - 1] += graph[r - 1][c - 1]
for i in range(4):
    ans = max(money[i][r - 1][c - 1], ans)

print(ans)
