#include <bits/stdc++.h>
using namespace std;
template <class T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int hp[20000 + 1];
int hg[10 + 1];
int g[20000][10];
int main() {
  int N, M, K;
  while (cin >> N >> M >> K) {
    memset(hp, 0, sizeof hp);
    memset(hg, 0, sizeof hg);
    for (int i = (int)0, _m = (int)N; i < _m; ++i) {
      for (int j = (int)0, _m = (int)M; j < _m; ++j) {
        cin >> g[i][j];
      }
    }
    for (int i = (int)0, _m = (int)K; i < _m; ++i) {
      int person, group;
      cin >> person >> group;
      person--;
      group--;
      hp[person]--;
      hg[group]++;
    }
    for (int i = (int)0, _m = (int)N; i < _m; ++i) {
      for (int j = (int)0, _m = (int)M; j < _m; ++j) {
        if (g[i][j]) hp[i] += hg[j];
      }
    }
    cout << hp[0];
    for (int i = (int)1, _m = (int)N; i < _m; ++i) cout << " " << hp[i];
    cout << endl;
  }
}
