<span style="font-size:14px;">#include<iostream>
#include <string.h>
using namespace std;
int a[200010][20];
int num1[200010];
int num2[20];
int main()
{
int n,m,k;
int a1,a2;
while (cin>>n>>m>>k)
{
memset(num1, 0, sizeof(num1));
memset(num2, 0, sizeof(num2));
for (int i=1;i<=n; i++)
{
for (int j=1; j<=m; j++)
{
cin>>a[i][j];
}
}
for (int i=0; i<k; i++)
{
cin>>a1>>a2;
num1[a1]++;
num2[a2]++;
}
int sum;
for (int i=1; i<=n; i++)
{
sum=0;
for (int j=1; j<=m; j++)
{
if(a[i][j])
{
sum+=num2[j];
}
}
num1[i]=sum-num1[i];
}
for (int i=1; i<=n; i++)
{
if(i==n)
{
cout<<num1[i]<<endl;
continue;
}
cout<<num1[i]<<" ";
}
}
return 0;
}</span>