output_description: Print the maximum number of consecutive rainy days in the period.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: def run():
      # sys.stdin.readline()
      import sys
  
      input = sys.stdin.readline
      r, c, k = map(int, input().split())
      t = [[0 for i in range(c)] for i in range(r)]
      for i in range(k):
          a, b, z = map(int, input().split())
          t[a - 1][b - 1] = z
      t = tuple(t)
      dp = [[[0 for i in range(c)] for i in range(r)] for i in range(4)]
      dp[0][0][0] = 0
      dp[1][0][0] = t[0][0]
      dp[2][0][0] = t[0][0]
      dp[3][0][0] = t[0][0]
      for i in range(r - 1):
          dp[0][i + 1][0] = dp[1][i][0]
          for j in range(1, 4):
              dp[j][i + 1][0] = dp[1][i][0] + t[i + 1][0]
      for i in range(c - 1):
          dp[0][0][i + 1] = 0
          for j in range(1, 4):
              dp[j][0][i + 1] = max(dp[1][0][i], t[0][i + 1])
          for j in range(2, 4):
              dp[j][0][i + 1] = max(dp[2][0][i], dp[1][0][i] + t[0][i + 1])
          dp[3][0][i + 1] = max(dp[3][0][i], dp[2][0][i] + t[0][i + 1])
      for i in range(r - 1):
          for j in range(c - 1):
              u = max(dp[0][i + 1][j], dp[3][i][j + 1])
              for s in range(0, 4):
                  dp[s][i + 1][j + 1] = u
              u = max(
                  dp[0][i + 1][j] + t[i + 1][j + 1],
                  dp[1][i + 1][j],
                  dp[3][i][j + 1] + t[i + 1][j + 1],
              )
              for s in range(1, 4):
                  dp[s][i + 1][j + 1] = u
              u = max(
                  dp[1][i + 1][j] + t[i + 1][j + 1],
                  dp[2][i + 1][j],
                  dp[3][i][j + 1] + t[i + 1][j + 1],
              )
              for s in range(2, 4):
                  dp[s][i + 1][j + 1] = u
              dp[3][i + 1][j + 1] = max(
                  dp[2][i + 1][j] + t[i + 1][j + 1],
                  dp[3][i + 1][j],
                  dp[3][i][j + 1] + t[i + 1][j + 1],
              )
      print(dp[3][r - 1][c - 1])
  
  
  if __name__ == "__main__":
      run()
  
problem_description: Statement
  
  We have weather records at AtCoder Town for some consecutive three days. A
  string of length 3, S, represents the records - if the i-th character is `S`,
  it means it was sunny on the i-th day; if that character is `R`, it means it
  was rainy on that day.
  
  Find the maximum number of consecutive rainy days in this period.
samples: [{"input": "RRS", "output": "2\n    \n\nWe had rain on the 1-st and 2-nd days in the period. Here, the maximum number\nof consecutive rainy days is 2, so we should print 2.\n\n* * *"}, {"input": "SSS", "output": "0\n    \n\nIt was sunny throughout the period. We had no rainy days, so we should print\n0.\n\n* * *"}, {"input": "RSR", "output": "1\n    \n\nWe had rain on the 1-st and 3-rd days - two \"streaks\" of one rainy day, so we\nshould print 1."}]