#include <bits/stdc++.h>
using namespace std;
const int N = 505;
const long long oo = 1e18;
vector<pair<int, long long>> row[N][N], col[N][N];
long long dp[N][N];
long long a[N][N];
int n, m, k;
void mini(long long &a, long long b) {
  if (a > b) a = b;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= k; i++) {
    int x, y, d, t, w;
    cin >> x >> y >> d >> t >> w;
    if (x + y >= t) {
      if ((x + y - t) % 4 == 0) {
        a[x][y] += w;
        if ((x + y + d - t) % 4 == 3)
          row[x][y + d].push_back(make_pair(-y, -w));
        if ((x + y + d - t) % 4 == 2)
          col[x + d][y].push_back(make_pair(-x, -w));
      }
      if ((x + y - t) % 4 == 1) {
        a[x + d][y - d] += w;
        if ((x + y + d - t) % 4 == 2)
          row[x + d][y].push_back(make_pair(-(y - d), -w));
      }
    }
    if (x + y + d >= t) {
      if ((x + y + d - t) % 4 == 2) a[x + d][y] += w;
      if ((x + y + d - t) % 4 == 3) a[x][y + d] += w;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      sort(row[i][j].begin(), row[i][j].end());
      for (int id = 1; id < (int)row[i][j].size(); id++)
        row[i][j][id].second += row[i][j][id - 1].second;
      sort(col[i][j].begin(), col[i][j].end());
      for (int id = 1; id < (int)col[i][j].size(); id++)
        col[i][j][id].second += col[i][j][id - 1].second;
      dp[i][j] = oo;
    }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      long long sum;
      sum = dp[i][j];
      for (int k = j + 1; k < m; k++) {
        sum += a[i][k];
        auto it =
            upper_bound(row[i][k].begin(), row[i][k].end(), make_pair(-j, oo));
        if (it != row[i][k].begin()) sum += prev(it)->second;
        mini(dp[i][k], sum);
      }
      sum = dp[i][j];
      for (int k = i + 1; k < n; k++) {
        sum += a[k][j];
        auto it =
            upper_bound(col[k][j].begin(), col[k][j].end(), make_pair(-i, oo));
        if (it != col[k][j].begin()) sum += prev(it)->second;
        mini(dp[k][j], sum);
      }
    }
  cout << dp[n - 1][m - 1];
  return 0;
}
