#include <bits/stdc++.h>
const int N = 505;
long long a[N][N], dpr[2][N][N], dpd[2][N][N], ans = 1e18;
int n, m, k, x, y, d, t, v;
struct note {
  int v, d;
};
void upd(long long &x, long long y) {
  if (y < x) x = y;
}
std::vector<note> vd[N][N], vr[N][N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= k; i++) {
    scanf("%d%d%d%d%d", &x, &y, &d, &t, &v);
    int f0 = 0, f1 = 0, f2 = 0, f3 = 0;
    if (t <= x + y && (x + y - t) % 4 == 0) f0 = 1, a[x][y] += v;
    if (t + 1 <= (x + d) + (y - d) && (x + d + y - d - t - 1) % 4 == 0)
      f1 = 1, a[x + d][y - d] += v;
    if (t + 2 <= (x + d) + y && ((x + d + y - t - 2) % 4 == 0))
      f2 = 1, a[x + d][y] += v;
    if (t + 3 <= x + (y + d) && ((x + y + d - t - 3) % 4 == 0))
      f3 = 1, a[x][y + d] += v;
    if (f0 && f3) vd[x][y + d].push_back({v, d});
    if (f1 && f2) vd[x + d][y].push_back({v, d});
    if (f0 && f2) vr[x + d][y].push_back({v, d});
  }
  int now = 0;
  memset(dpr, 0x3f, sizeof(dpr));
  memset(dpd, 0x3f, sizeof(dpd));
  dpr[0][0][0] = 0, dpd[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    memset(dpr[now ^ 1], 0x3f, sizeof(dpr[now ^ 1]));
    memset(dpd[now ^ 1], 0x3f, sizeof(dpd[now ^ 1]));
    for (int j = 0; j < m; j++) {
      for (int k = 0; k <= i; k++) {
        long long &t = dpr[now][j][k];
        t += a[i][j];
        for (auto u : vr[i][j])
          if (u.d <= k) t -= u.v;
        upd(dpr[now ^ 1][j][k + 1], t);
        upd(dpd[now][j + 1][1], t);
      }
      for (int k = 0; k <= j; k++) {
        long long &t = dpd[now][j][k];
        t += a[i][j];
        for (auto u : vd[i][j])
          if (u.d <= k) t -= u.v;
        upd(dpr[now ^ 1][j][1], t);
        upd(dpd[now][j + 1][k + 1], t);
      }
    }
    now = now ^ 1;
  }
  for (int i = 0; i < n; i++) ans = std::min(ans, dpr[now ^ 1][m - 1][i]);
  for (int i = 0; i < m; i++) ans = std::min(ans, dpd[now ^ 1][m - 1][i]);
  printf("%lld\n", ans);
}
