#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[20001][11];
int group[11];
pair<int, int> chat[200001];
int ans[20001];
int main() {
  cin >> n;
  cin >> m;
  cin >> k;
  for (int i = 1; i <= 10; i++) {
    group[i] = 0;
  }
  for (int i = 1; i <= 20001; i++) {
    ans[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int i2 = 1; i2 <= m; i2++) {
      cin >> a[i][i2];
    }
  }
  for (int i = 1; i <= k; i++) {
    cin >> chat[i].first;
    cin >> chat[i].second;
  }
  for (int i = 1; i <= k; i++) {
    group[chat[i].second]++;
  }
  for (int i = 1; i <= m; i++) {
    for (int i2 = 1; i2 <= n; i2++) {
      if (a[i2][i] == 1) {
        ans[i2] += group[i];
      }
    }
  }
  for (int i = 1; i <= k; i++) {
    ans[chat[i].first]--;
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
}
