#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int SUM = 0, ff = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    SUM = (SUM << 3) + (SUM << 1) + (ch ^ 48);
    ch = getchar();
  }
  return SUM * ff;
}
const int N = 510;
const long long inf = 1ll << 50;
int n, m, k;
long long a[N][N];
long long dp[2][N][N];
vector<pair<int, int> > ex[N][N], ey[N][N];
int main() {
  n = read(), m = read(), k = read();
  for (int i = 1; i <= k; i++) {
    int x = read(), y = read(), d = read(), t = read(), e = read();
    if (x + y >= t && ((x + y) - t) % 4 == 0) {
      a[x][y] += e;
      if (x + d + y >= t && ((x + d + y) - t) % 4 == 2) {
        ex[x + d][y].push_back(make_pair(d, e));
      }
      if (x + y + d >= t && ((x + y + d) - t) % 4 == 3) {
        ey[x][y + d].push_back(make_pair(d, e));
      }
    }
    if (x + d + y - d >= t && ((x + d + y - d) - t) % 4 == 1) {
      a[x + d][y - d] += e;
      if (x + d + y >= t && ((x + d + y) - t) % 4 == 2) {
        ey[x + d][y].push_back(make_pair(d, e));
      }
    }
    if (x + d + y >= t && ((x + d + y) - t) % 4 == 2) {
      a[x + d][y] += e;
    }
    if (x + y + d >= t && ((x + y + d) - t) % 4 == 3) {
      a[x][y + d] += e;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dp[0][i][j] = dp[1][i][j] = inf;
  dp[0][0][0] = dp[1][0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      sort(ex[i][j].begin(), ex[i][j].end());
      sort(ey[i][j].begin(), ey[i][j].end());
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long cost = dp[0][i][j];
      for (int k = 1; k + i < n; k++) {
        cost += a[i + k][j];
        for (int w = 0; w < (int)ex[i + k][j].size(); w++) {
          if (i + k - ex[i + k][j][w].first >= i)
            cost -= ex[i + k][j][w].second;
          else
            break;
        }
        dp[1][i + k][j] = min(dp[1][i + k][j], cost);
      }
      cost = dp[1][i][j];
      for (int k = 1; k + j < m; k++) {
        cost += a[i][j + k];
        for (int w = 0; w < ey[i][j + k].size(); w++) {
          if (j + k - ey[i][j + k][w].first >= j)
            cost -= ey[i][j + k][w].second;
          else
            break;
        }
        dp[0][i][j + k] = min(dp[0][i][j + k], cost);
      }
    }
  printf("%lld\n", min(dp[0][n - 1][m - 1], dp[1][n - 1][m - 1]));
  return 0;
}
