struct Scanner {
    private var elements = [String]()
    private var index = 0

    mutating func peek() -> String {
        while elements.count == index {
            elements = readLine()!.split(separator: " ").map(String.init)
            index = 0
        }
        return elements[index]
    }

    mutating func next() -> String {
        let value = peek()
        index += 1
        return value
    }

    mutating func nextInt() -> Int {
        return Int(next())!
    }

    mutating func nextDouble() -> Double {
        return Double(next())!
    }
}

var scanner = Scanner()
let R = scanner.nextInt()
let C = scanner.nextInt()
let K = scanner.nextInt()

struct Array2D<Element> {
    let n1: Int
    let n2: Int
    private var elements: [Element]

    init(repeating: Element, _ n1: Int, _ n2: Int) {
        self.n1 = n1
        self.n2 = n2
        self.elements = [Element](repeating: repeating, count: n1 * n2)
    }

    subscript(i: Int, j: Int) -> Element {
        get {
            elements[i * n2 + j]
        }
        set {
            elements[i * n2 + j] = newValue
        }
    }
}

struct Array3D<Element> {
    let n1: Int
    let n2: Int
    let n3: Int
    private var elements: [Element]

    init(repeating: Element, _ n1: Int, _ n2: Int, _ n3: Int) {
        self.n1 = n1
        self.n2 = n2
        self.n3 = n3
        self.elements = [Element](repeating: repeating, count: n1 * n2 * n3)
    }

    subscript(i: Int, j: Int, k: Int) -> Element {
        get {
            elements[(i * n2 + j) * n3 + k]
        }
        set {
            elements[(i * n2 + j) * n3 + k] = newValue
        }
    }
}

infix operator ++=: AssignmentPrecedence

extension Int {
    static func ++= (lhs: inout Int, rhs: Int) {
        if lhs < rhs {
            lhs = rhs
        }
    }
}



var V = Array2D(repeating: 0, R, C)
for _ in 0 ..< K {
    let r = scanner.nextInt() - 1
    let c = scanner.nextInt() - 1
    V[r, c] = scanner.nextInt()
}

var dp = Array3D<Int>(repeating: Int.min, R, C, 5)
dp[0, 0, 0] = 0
dp[0, 0, 1] = V[0, 0]

for i in 0 ..< R {
    for j in 0 ..< C {
        for k in 0 ... 3 {
            if i + 1 < R {
                dp[i + 1, j, 0] ++= dp[i, j, k]
                dp[i + 1, j, 1] ++= dp[i, j, k] + V[i + 1, j]
            }

            if j + 1 < C {
                dp[i, j + 1, k] ++= dp[i, j, k]
                dp[i, j + 1, k + 1] ++= dp[i, j, k] + V[i, j + 1]
            }
        }
    }
}

let answer = (0 ... 3).map { dp[R - 1, C - 1, $0] }.max()!
print(answer)


