include[HTML_REMOVED]
using namespace std;
int a[1002][1002], b[1002][1002];//1002才会不溢出,因为后面有个++
int n, m, q, x, y, xx, yy, c, i, j;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
cin >> n >> m >> q;
for (i = 1; i <= n; i)
for (j = 1; j <= m; j)
{
cin >> a[i][j];
b[i][j] = a[i][j];
b[i][j] -= a[i-1][j];
b[i][j] -= a[i][j-1];
b[i][j] += a[i-1][j-1];
}//这里需要理解一番,一开始总出错
for (i = 1; i <= q; i++)
{
cin >> x >> y >> xx >> yy >> c;
b[x][y] += c;
b[xx +1][y] -= c;
b[x][yy+1] -= c;
b[xx+ 1][yy+ 1] += c;
}
for (i = 1; i <= n; i++)
{
for (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 << endl;
}
}