#include <bits/stdc++.h>
using ll = long long;
const int N = 500 + 5;
const int dx[] = {0, 1, 1, 0};
const int dy[] = {0, -1, 0, 1};
int n, m, k;
ll dp[N][N], val[N][N];
std::vector<std::pair<int, ll> > prex[N][N], prey[N][N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int _ = 0; _ < k; _++) {
    int x, y, d, t, e;
    bool vis[4] = {false};
    scanf("%d%d%d%d%d", &x, &y, &d, &t, &e);
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i] * d, ny = y + dy[i] * d;
      if (nx + ny >= t && (nx + ny - t) % 4 == i) {
        vis[i] = true;
        val[nx][ny] += e;
      }
    }
    if (vis[0] && vis[2]) {
      prex[x + d][y].emplace_back(x, e);
    }
    if (vis[0] && vis[3]) {
      prey[x][y + d].emplace_back(y, e);
    }
    if (vis[1] && vis[2]) {
      prey[x + d][y].emplace_back(y - d, e);
    }
  }
  memset(dp, 0x3f, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      ll cur = dp[i][j];
      for (int x = i + 1; x < n; x++) {
        cur += val[x][j];
        for (auto p : prex[x][j]) {
          if (p.first >= i) {
            cur -= p.second;
          }
        }
        dp[x][j] = std::min(dp[x][j], cur);
      }
      cur = dp[i][j];
      for (int y = j + 1; y < m; y++) {
        cur += val[i][y];
        for (auto p : prey[i][y]) {
          if (p.first >= j) {
            cur -= p.second;
          }
        }
        dp[i][y] = std::min(dp[i][y], cur);
      }
    }
  }
  printf("%lld\n", dp[n - 1][m - 1]);
  return 0;
}
