#include using namespace std; const int maxn = 1001; int n, m, q; int a[maxn][maxn]; vector row[maxn], col[maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ifstream in("scenery.in"); ofstream out("scenery.out"); in >> n >> m >> q; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ in >> a[i][j]; } } for(int j = 0;j < q;j++){ int x, y; in >> x >> y; row[x].push_back(y); col[y].push_back(x); } int sz; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ sz = row[i].size(); for(int k = 0;k < sz;k++){ a[i][j] -= abs(row[i][k] - j); } sz = col[j].size(); for(int k = 0;k < sz;k++){ a[i][j] -= abs(col[j][k] - i); } out << a[i][j] << " "; } out << endl; } return 0; }