//  #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
//  做这一题之前最好先做差分(一维),然后根据一维中的原数组是差分数组的前缀和就可以大概感觉出二位差分与原数组的关系,然后画图来推需要的操作,再去网上看看和别人的一不一样,是否要优化。
#include <iostream>
#include <vector>
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n, m, q;
  cin >> n >> m >> q;
  vector<vector<long long>> a(n + 1, vector<long long>(m + 1, 0)), b(n + 1, vector<long long>(m + 1, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> a[i + 1][j + 1];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      b[i][j] = a[i][j] - a[i - 1][j] - a[i][j - 1] + a[i - 1][j - 1];
  int x, y, xx, yy, k;
  while(q--){
    cin >> x >> y >> xx >> yy >> k;
    b[x][y] += k;
    if (yy + 1 <= m)
      b[x][yy + 1] -= k;
    if (xx + 1 <= n)
      b[xx + 1][y] -= k;
    if (yy + 1 <= m && xx + 1 <= n)
      b[xx + 1][yy + 1] += k;
  }
  for (int i = 1; i <= n; i++){
    for (int j = 1; j <= m; j++){
      a[i][j] = a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1] + b[i][j];
      cout << a[i][j] << " ";
    }
    cout << "\n";
  }
}
// 64 位输出请用 printf("%lld")