#include <bits/stdc++.h>
using namespace std;
const int N = 502;
int n, m, k;
struct PaiGuLong {
  int t, d, e, id;
};
vector<PaiGuLong> v[N][N];
long long dp[2][N][N][2];
void upd(int x, int y, int len, int dir) {
  if (x < n - 1) {
    if (dir == 0) {
      dp[(x + 1) % 2][y][len + 1][dir] =
          min(dp[(x + 1) % 2][y][len + 1][dir], dp[x % 2][y][len][dir]);
    } else {
      dp[(x + 1) % 2][y][1][0] =
          min(dp[(x + 1) % 2][y][1][0], dp[x % 2][y][len][dir]);
    }
  }
  if (y < m - 1) {
    if (dir == 1) {
      dp[x % 2][y + 1][len + 1][dir] =
          min(dp[x % 2][y + 1][len + 1][dir], dp[x % 2][y][len][dir]);
    } else {
      dp[x % 2][y + 1][1][1] =
          min(dp[x % 2][y + 1][1][1], dp[x % 2][y][len][dir]);
    }
  }
}
long long det[N][2], cost[N][N];
void init_det(int x, int y) {
  memset(det, 0, sizeof(det));
  for (auto paigu : v[x][y]) {
    if (paigu.id + paigu.t > x + y) continue;
    if ((paigu.id + paigu.t) % 4 != (x + y) % 4) continue;
    if (paigu.id == 2) {
      if (0 + paigu.t <= x - paigu.d + y &&
          (0 + paigu.t) % 4 == (x - paigu.d + y) % 4)
        det[paigu.d][0] += paigu.e;
      if (1 + paigu.t <= x + y - paigu.d &&
          (1 + paigu.t) % 4 == (x + y - paigu.d) % 4)
        det[paigu.d][1] += paigu.e;
    }
    if (paigu.id == 3) {
      if (0 + paigu.t <= x + y - paigu.d &&
          (0 + paigu.t) % 4 == (x + y - paigu.d) % 4)
        det[paigu.d][1] += paigu.e;
    }
  }
  for (int i = 1; i <= max(n, m); i++) {
    det[i][0] += det[i - 1][0];
    det[i][1] += det[i - 1][1];
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    int x, y, d, t, e;
    scanf("%d%d%d%d%d", &x, &y, &d, &t, &e);
    v[x][y].push_back((PaiGuLong){t, d, e, 0});
    v[x + d][y - d].push_back((PaiGuLong){t, d, e, 1});
    v[x + d][y].push_back((PaiGuLong){t, d, e, 2});
    v[x][y + d].push_back((PaiGuLong){t, d, e, 3});
  }
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      for (auto paigu : v[x][y]) {
        if (paigu.id + paigu.t > x + y) continue;
        if ((paigu.id + paigu.t) % 4 != (x + y) % 4) continue;
        cost[x][y] += paigu.e;
      }
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      for (int k = 0; k <= max(n, m); k++)
        dp[i % 2][j][k][0] = dp[i % 2][j][k][1] = 1e18;
  dp[0][0][0][0] = dp[0][0][0][1] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k <= max(n, m); k++) {
        for (int dir = 0; dir < 2; dir++) {
          dp[(i + 1) % 2][j][k][dir] = 1e18;
        }
      }
    }
    for (int j = 0; j < m; j++) {
      init_det(i, j);
      for (int k = 0; k <= max(n, m); k++) {
        for (int dir = 0; dir < 2; dir++) {
          dp[i % 2][j][k][dir] += cost[i][j] - det[k][dir];
          upd(i, j, k, dir);
        }
      }
    }
  }
  long long ans = 1e18;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, dp[(n - 1) % 2][m - 1][i][0]);
  }
  for (int i = 0; i <= m; i++) {
    ans = min(ans, dp[(n - 1) % 2][m - 1][i][1]);
  }
  printf("%lld\n", ans);
}
