#include <bits/stdc++.h>
using namespace std;
int matrix[20005][20], rec[20005], flag[20005][20];
int main(void) {
  int n, m, k, i, a, b, j, tmp;
  while (scanf("%d%d%d", &n, &m, &k) != EOF) {
    memset(flag, 0, sizeof(flag));
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        scanf("%d", &matrix[i][j]);
      }
    }
    memset(rec, 0, sizeof(rec));
    while (k--) {
      scanf("%d%d", &a, &b);
      flag[a][b]++;
    }
    for (i = 1; i <= m; i++) {
      tmp = 0;
      for (j = 1; j <= n; j++) {
        tmp += flag[j][i];
      }
      for (j = 1; j <= n; j++) {
        if (matrix[j][i]) rec[j] += tmp - flag[j][i];
      }
    }
    for (i = 1; i <= n - 1; i++) {
      printf("%d ", rec[i]);
    }
    printf("%d\n", rec[i]);
  }
  return 0;
}
