#include <bits/stdc++.h>
using namespace std;
int b[11], p[20001];
int main(int argc, char *argv[]) {
  int n, m, k, i, j, x, y;
  scanf("%d %d %d", &n, &m, &k);
  vector<set<int> > V(m + 1);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &x);
      if (x) V[j].insert(i);
    }
  for (i = 1; i <= k; i++) {
    scanf("%d %d", &x, &y);
    p[x]++;
    b[y]++;
  }
  for (i = 1; i < n; i++) {
    for (x = 0, j = 1; j <= m; j++)
      if (V[j].count(i)) x += b[j];
    printf("%d ", x - p[i]);
  }
  for (x = 0, j = 1; j <= m; j++)
    if (V[j].count(n)) x += b[j];
  printf("%d", x - p[i]);
  return EXIT_SUCCESS;
}
