object Main extends App {
  val sc = new FastScanner(System.in)
  val r, c, k = sc.nextInt()
  val rcv = List.fill(k)((sc.nextInt()-1, sc.nextInt()-1, sc.nextLong()))

  val v = Array.fill(r, c)(0L)
  for ((ri, ci, vi) <- rcv) {
    v(ri)(ci) = vi
  }

  val dp = Array.fill(r, c, 4)(0L)
  def maxOfDp(x1: Int, x2: Int): Long = {
    dp(x1)(x2)(0).max(
      dp(x1)(x2)(1)).max(
      dp(x1)(x2)(2)).max(
      dp(x1)(x2)(3))
  }

  dp(0)(0)(1) = v(0)(0)
  for {
    i <- 0 until r
    j <- 0 until c
    k <- 0 to 3
    if !(i == 0 && j == 0)
  } {
    var x = Long.MinValue
    if (k <= 1 && i != 0) {
      x = x.max(maxOfDp(i-1, j) + (if (k == 1) v(i)(j) else 0))
    }

    if (j != 0) {
      x = x.max(dp(i)(j-1)(k))
      if (k != 0) {
        x = x.max(dp(i)(j-1)(k-1) + v(i)(j))
      }
    }
    dp(i)(j)(k) = x
  }

  println(maxOfDp(r-1, c-1))
}

class FastScanner(source: java.io.InputStream) {
  val buf = new Array[Byte](1024)
  var now, end = 0

  def isPrintable(b: Byte): Boolean = 33 <= b && b <= 126
  def isNum(b: Byte): Boolean = 48 <= b && b <= 57

  def hasNextByte: Boolean = {
    if (now < end) {
      true
    } else {
      now = 0
      end = source.read(buf)
      end > 0
    }
  }

  def nextByte(): Byte = {
    if (hasNextByte) {
      val b = buf(now)
      now += 1
      b
    } else {
      -1
    }
  }

  def hasNext: Boolean = {
    while (hasNextByte && !isPrintable(buf(now))) {
      now += 1
    }
    hasNextByte
  }

  def next(): String = {
    if (hasNext) {
      val sb = new StringBuilder()
      var b = nextByte()
      while (isPrintable(b)) {
        sb += b.toChar
        b = nextByte()
      }
      sb.toString
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextInt(): Int = {
    nextLong().toInt
  }

  def nextLong(): Long = {
    if (hasNext) {
      var b = nextByte()
      var sign = 1
      var n = 0L
      if (b == '-') {
        sign = -1
        b = nextByte()
      }
      while (isNum(b)) {
        n = n * 10 + (b - 48)
        b = nextByte()
      }
      sign * n
    } else {
      throw new NoSuchElementException()
    }
  }

  def nextDouble(): Double = next().toDouble
}
