#include <bits/stdc++.h>
using namespace std;
long long cost[505][505], dp[505][505], tag[505];
vector<pair<int, int> > W0[505][505], W1[505][505];
int main() {
  int n, m, k, x, y, d, t, c;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d%d", &x, &y, &d, &t, &c);
    pair<int, int> g1 = pair<int, int>(-1, -1), g2 = pair<int, int>(-1, -1);
    if ((x + y) >= t && (x + y - t) % 4 == 0) g1 = pair<int, int>(x, y);
    if ((x + y) >= t && (x + y - t) % 4 == 1) g1 = pair<int, int>(x + d, y - d);
    if ((x + y + d) >= t && (x + y + d - t) % 4 == 2)
      g2 = pair<int, int>(x + d, y);
    if ((x + y + d) >= t && (x + y + d - t) % 4 == 3)
      g2 = pair<int, int>(x, y + d);
    if (g1.first != -1) cost[g1.first][g1.second] += c;
    if (g2.first != -1) cost[g2.first][g2.second] += c;
    if (g1.first != -1 && g2.first != -1) {
      if (g1.first != g2.first && g1.second != g2.second) continue;
      if (g1.first == g2.first)
        W0[g1.first][g1.second].push_back(pair<int, int>(g2.second, c));
      else
        W1[g1.first][g1.second].push_back(pair<int, int>(g2.first, c));
    }
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0][0] = cost[0][0];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost[i + 1][j]);
      dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost[i][j + 1]);
      if (W0[i][j].size()) {
        long long sum = 0;
        for (int k = j; k < m; k++) {
          if (k != j) sum += cost[i][k];
          for (int t = 0; t < (int)W0[i][k].size(); t++) {
            pair<int, int> g = W0[i][k][t];
            tag[g.first] += g.second;
          }
          sum -= tag[k], tag[k] = 0;
          dp[i][k] = min(dp[i][k], dp[i][j] + sum);
        }
      }
      if (W1[i][j].size()) {
        long long sum = 0;
        for (int k = i; k < n; k++) {
          if (k != i) sum += cost[k][j];
          for (int t = 0; t < (int)W1[k][j].size(); t++) {
            pair<int, int> g = W1[k][j][t];
            tag[g.first] += g.second;
          }
          sum -= tag[k], tag[k] = 0;
          dp[k][j] = min(dp[k][j], dp[i][j] + sum);
        }
      }
    }
  }
  printf("%lld\n", dp[n - 1][m - 1]);
  return 0;
}
