#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(a.print(), o) {
  o << "{";
  a.print();
  o << "}";
  return o;
};
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(a.second, o) {
  o << "(" << a.first << ", " << a.second << ")";
  return o;
};
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype((a).begin(), (a).end(), o) {
  o << "[";
  auto d = "";
  for (auto i : a) (o << d << i, d = ", ");
  o << "]";
  return o;
};
void DD(...) {}
template <class t, class u, class... w>
void DD(t s, u a, w... k) {
  int b = 44;
  while (*s && *s != b) {
    b += (*s == 40 ? 50 : *s == 41 ? -50 : 0);
    cerr << *s++;
  }
  cerr << ": " << a << *s++;
  DD(s, k...);
}
template <class t, class u, class... w>
vector<t> span(const t* a, u n) {
  return {a, a + n};
}
constexpr ll INF = 1e18;
struct Change {
  int first, second, cost;
};
vector<Change> changesX[505][505], changesY[505][505];
ll dp[505][505], costX[505][505], costY[505][505];
bool collide(int first, int second, int t) {
  return first + second >= t && (first + second - t) % 4 == 0;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = (0); i < (k); i++) {
    int first, second, d, t, e;
    cin >> first >> second >> d >> t >> e;
    if (collide(first, second, t)) {
      costX[first][second] += e;
      costY[first][second] += e;
    }
    if (collide(first + d, second - d, t + 1)) {
      costX[first + d][second - d] += e;
      costY[first + d][second - d] += e;
    }
    if (collide(first + d, second, t + 2)) {
      if (collide(first + d, second - d, t + 1)) {
        changesX[first + d][second - d].push_back({first + d, second, e});
      } else {
        costX[first + d][second] += e;
      }
      if (collide(first, second, t)) {
        changesY[first][second].push_back({first + d, second, e});
      } else {
        costY[first + d][second] += e;
      }
    }
    if (collide(first, second + d, t + 3)) {
      if (collide(first, second, t)) {
        changesX[first][second].push_back({first, second + d, e});
      } else {
        costX[first][second + d] += e;
      }
      costY[first][second + d] += e;
    }
  }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) dp[i][j] = INF;
  dp[0][0] = costX[0][0];
  for (int first = (0); first < (n); first++)
    for (int second = (0); second < (m); second++) {
      ll tmp = dp[first][second];
      for (int j = first + 1; j < n; j++) {
        tmp += costY[j][second];
        dp[j][second] = min(dp[j][second], tmp);
      }
      tmp = dp[first][second];
      for (int j = second + 1; j < m; j++) {
        tmp += costX[first][j];
        dp[first][j] = min(dp[first][j], tmp);
      }
      for (auto& p : (changesX[first][second]))
        costX[p.first][p.second] += p.cost;
      for (auto& p : (changesY[first][second]))
        costY[p.first][p.second] += p.cost;
    }
  cout << dp[n - 1][m - 1] << '\n';
}
