#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  long long int n, m, k, aux, x, y, cont = 0, i;
  cin >> n >> m >> k;
  vector<vector<int> > matriz(n + 1, vector<int>(m + 1));
  vector<int> rst(n + 1);
  vector<int> call(m + 1);
  vector<int> person(n + 1);
  map<int, list<int> > mapa;
  map<int, list<int> >::iterator ita;
  list<int>::iterator it;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      cin >> aux;
      if (aux == 1)
        mapa[i].push_back(j);
      else
        mapa[i].push_back(0);
    }
  }
  for (long long int i = 0; i < k; i++) {
    cin >> x >> y;
    call[y]++;
    person[x]++;
  }
  i = 0;
  for (ita = mapa.begin(); ita != mapa.end(); ++ita) {
    for (it = ita->second.begin(); it != ita->second.end(); ++it) {
      rst[i] += call[*it];
      cont++;
    }
    cont = 0;
    i++;
  }
  cout << rst[0] - person[1];
  for (long long int i = 1; i < n; i++) {
    cout << " " << rst[i] - person[i + 1];
  }
  cout << "\n";
  return 0;
}
