#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
int n, m, k;
int tot[15];
int res[20005];
int belong[20005][15];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) {
      int t;
      cin >> t;
      belong[i][j] = t;
    }
  for (int i = 0; i < (k); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    ++tot[y];
    --res[x];
  }
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) res[i] += tot[j] * belong[i][j];
  for (int i = 0; i < (n); ++i) cout << res[i] << (i == n - 1 ? '\n' : ' ');
  return 0;
}
