#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<vector<int>> a(n + 2, vector<int>(n + 2, 0));
for (int i = 0; i < m; i++) {
int e, x1, y1, x2, y2;
cin >> e >> x1 >> y1 >> x2 >> y2;
a[x1][y1] += e;
a[x1][y2 + 1] -= e;
a[x2 + 1][y1] -= e;
a[x2 + 1][y2 + 1] += e;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cout << a[i][j] << " \n"[j == n];
}
}
return 0;
}