#include <bits/stdc++.h>
using namespace std;
long long cnt[20], calc[20], mas[40000][20], ans[40000];
vector<vector<int> > wr(40000);
int main() {
  ios_base::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cin >> mas[i][j];
      if (mas[i][j]) cnt[j] += 1;
    }
  }
  for (int i = 0; i < K; i++) {
    int a, b;
    cin >> a >> b;
    a -= 1, b -= 1;
    wr[a].push_back(b);
    calc[b] += 1;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < (int)wr[i].size(); j++) {
      ans[i] -= 1;
    }
    for (int j = 0; j < M; j++) {
      if (mas[i][j]) ans[i] += calc[j];
    }
  }
  for (int i = 0; i < N; i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
