#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

int n,m,k,a[200000][20],multi[100],mis[100];

bool comp(int a,int b){
    return(a<b);
}

bool isc(char a){
    return(49<=a-'0'&&74>=a-'0');
}

bool isa(char a){
    return(0<=a-'0'&&9>=a-'0');
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int tmp,notplus;
    for(int i=0;i<k;i++){
        scanf("%d%d", &notplus,&tmp);
        notplus--;
        tmp--;
        multi[tmp]++;
        mis[notplus]--;
    }
    for(int i=0;i<n;i++){
            int ans=mis[i];
        for(int j=0;j<m;j++){
            ans+=a[i][j]*multi[j];
        }
        printf("%d ",ans);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

int n,m,k,a[100000][20],ans[100000];

bool comp(int a,int b){
    return(a<b);
}

bool isc(char a){
    return(49<=a-'0'&&74>=a-'0');
}

bool isa(char a){
    return(0<=a-'0'&&9>=a-'0');
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int tmp,notplus;
    for(int i=0;i<k;i++){
        scanf("%d %d", &notplus,&tmp);
        tmp--;
        for(int j=0;j<n;j++){
            if(a[j][tmp]==1&&j!=notplus-1)
                ans[j]++;
              //  cout<<ans[j]<<' ';
        }
    }
    for(int i=0;i<n;i++){
        printf("%d ",ans[i]);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

int n,m,k,a[200000][20],multi[100],mis[200000];

bool comp(int a,int b){
    return(a<b);
}

bool isc(char a){
    return(49<=a-'0'&&74>=a-'0');
}

bool isa(char a){
    return(0<=a-'0'&&9>=a-'0');
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int tmp,notplus;
    for(int i=0;i<k;i++){
        scanf("%d%d", &notplus,&tmp);
        notplus--;
        tmp--;
        multi[tmp]++;
        mis[notplus]--;
    }
    for(int i=0;i<n;i++){
            int ans=mis[i];
        for(int j=0;j<m;j++){
            ans+=a[i][j]*multi[j];
        }
        printf("%d ",ans);
    }
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

int n,m,k,a[100000][20],multi[100],mis[100];

bool comp(int a,int b){
    return(a<b);
}

bool isc(char a){
    return(49<=a-'0'&&74>=a-'0');
}

bool isa(char a){
    return(0<=a-'0'&&9>=a-'0');
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>k;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    int tmp,notplus;
    for(int i=0;i<k;i++){
        scanf("%d%d", &notplus,&tmp);
        notplus--;
        tmp--;
        multi[tmp]++;
        mis[notplus]--;
    }
    for(int i=0;i<n;i++){
            int ans=mis[i];
        for(int j=0;j<m;j++){
            ans+=a[i][j]*multi[j];
        }
        printf("%d ",ans);
    }
    return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
const int N = 10001;
const int M = 11;

int a[M][N];
int L[M];
int sent[M];
int res[M];
int n,m,k;

int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>m>>k;
	int u,v;
	for(int i=1;i <=n; i++){
		sent[i]=0;
		res[i]=0;
	}
	for(int i=1;i<=m;i++) L[i] =0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>a[i][j];
	for(int i=1; i<=k; i++){
		cin>>u>>v;
		sent[u] ++;
		L[v]++;
	}
	for(int i=1;i<=n; i++){
		for(int j=1;j<=m; j++)
			res[i]+=a[i][j]*L[j];
	}
	for(int i=1;i<=n;i++)
		cout<<res[i]-sent[i] <<" ";
}


#include <iostream>
#include <algorithm>
using namespace std;
const int N = 20001;
const int M = 11;

int a[M][N];
int L[M];
int sent[M];
int res[M];
int n,m,k;

int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>m>>k;
	int u,v;
	for(int i=1;i <=n; i++){
		sent[i]=0;
		res[i]=0;
	}
	for(int i=1;i<=m;i++) L[i] =0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>a[i][j];
	for(int i=1; i<=k; i++){
		cin>>u>>v;
		sent[u] ++;
		L[v]++;
	}
	for(int i=1;i<=n; i++){
		for(int j=1;j<=m; j++)
			res[i]+=a[i][j]*L[j];
	}
	for(int i=1;i<=n;i++)
		cout<<res[i]-sent[i] <<" ";
}


#include <iostream>
#include <algorithm>
using namespace std;
const int N = 20001;
const int M = 11;

int a[N][M];
int L[M];
int sent[N];
int res[N];
int n,m,k;

int main(){
	//freopen("in.txt","r",stdin);
	cin>>n>>m>>k;
	int u,v;
	for(int i=1;i <=n; i++){
		sent[i]=0;
		res[i]=0;
	}
	for(int i=1;i<=m;i++) L[i] =0;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>a[i][j];
	for(int i=1; i<=k; i++){
		cin>>u>>v;
		sent[u] ++;
		L[v]++;
	}
	for(int i=1;i<=n; i++){
		for(int j=1;j<=m; j++)
			res[i]+=a[i][j]*L[j];
	}
	for(int i=1;i<=n;i++)
		cout<<res[i]-sent[i] <<" ";
}


#include <bits/stdc++.h>
using namespace std;
#define pf pop_front
#define pb push_back
#define ulli unsigned long long int
#define FOR(i,begin,end) for (LL i=begin;i<=end;i++)
#define rep(i,t) for (LL i=0;i<t;i++)
#define LL __int64
#define pii pair<LL,LL>
const LL MAX=(2*1e4)+17,N=17,inf=1e18;
LL n,m,k,b[N],c[MAX],x,y;
bool a[MAX][N];
int main()
{
	cin>>n>>m>>k;
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			cin>>a[i][j];
		}
	}
	FOR(i,1,k)
	{
		cin>>x>>y;
		c[x]--;
		b[y]++;
	}
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			if(a[i][j])c[i]+=b[j];
		}
		cout<<c[i]<<" ";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pf pop_front
#define pb push_back
#define ulli unsigned long long int
#define FOR(i,begin,end) for (LL i=begin;i<=end;i++)
#define rep(i,t) for (LL i=0;i<t;i++)
#define LL __int64
#define pii pair<LL,LL>
const LL MAX=(1e4)+17,N=17,inf=1e18;
LL n,m,k,b[N],c[MAX],x,y;
bool a[MAX][N];
int main()
{
	cin>>n>>m>>k;
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			cin>>a[i][j];
		}
	}
	FOR(i,1,k)
	{
		cin>>x>>y;
		c[x]--;
		b[y]++;
	}
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			if(a[i][j])c[i]+=b[j];
		}
		cout<<c[i]<<" ";
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <string>
#include <list>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <deque>
#include <climits>
#include <cassert>

using namespace std;

#define ull unsigned long long
#define ll long long
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define Sl(x) scanf("%lld",&x)
#define Su(x) scanf("%llu",&x)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define S(x) scanf("%d",&x)
#define IS(x) cin>>x
#define ISF(x) getline(cin,x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define pps pair<ll,pll>
#define ppf pair<pll,ll>
#define psi pair<string,int>
#define pis pair<int,string>
#define fr first
#define se second
#define p(x) cout<<(x)
#define MOD 1000000007
#define eps 1e-7
#define V(x) vector<x>
#define pb(x) push_back(x)
#define mem(x,i) memset(x,i,sizeof(x))
#define fori(i,s,n) for(i=(s);i<(n);i++)
#define ford(i,s,n) for(i=(n);i>=(s);--i)
#define INF 8944674407370955161LL
#define debug(i,st,arr) fori(i,0,st){cout<<arr[i]<<" ";}cout<<endl;
#define forci(i,sw) for((i)=(sw).begin();(i)!=(sw).end();(i)++)
#define forcd(i,sw) for((i)=(sw).rbegin();(i)!=(sw).rend();(i)++)

int abs(int x) {if(x < 0) return -x; return x;}

int up[100005], lo[100005], a[1001][1001];

int main()
{
    int n, m, q;
    S(n), S(m);
    S(q);
    int i, j, x, y;
    fori(i, 0, n) {
        fori(j, 0, m) {
            S(a[i][j]);
        }
    }
    fori(i,0,q) {
        S(x), S(y);
        x--, y--;
        lo[x]--;
        up[y]++;
    }
    fori(i, 0, m) {
        fori(j, 0, n) {
            if(a[j][i]) lo[j] += up[i];
        }
    }
    fori(i,0,n) {
        cout << lo[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <string>
#include <list>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <deque>
#include <climits>
#include <cassert>

using namespace std;

#define ull unsigned long long
#define ll long long
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define Sl(x) scanf("%lld",&x)
#define Su(x) scanf("%llu",&x)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define S(x) scanf("%d",&x)
#define IS(x) cin>>x
#define ISF(x) getline(cin,x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define pps pair<ll,pll>
#define ppf pair<pll,ll>
#define psi pair<string,int>
#define pis pair<int,string>
#define fr first
#define se second
#define p(x) cout<<(x)
#define MOD 1000000007
#define eps 1e-7
#define V(x) vector<x>
#define pb(x) push_back(x)
#define mem(x,i) memset(x,i,sizeof(x))
#define fori(i,s,n) for(i=(s);i<(n);i++)
#define ford(i,s,n) for(i=(n);i>=(s);--i)
#define INF 8944674407370955161LL
#define debug(i,st,arr) fori(i,0,st){cout<<arr[i]<<" ";}cout<<endl;
#define forci(i,sw) for((i)=(sw).begin();(i)!=(sw).end();(i)++)
#define forcd(i,sw) for((i)=(sw).rbegin();(i)!=(sw).rend();(i)++)

int abs(int x) {if(x < 0) return -x; return x;}

int up[100005], lo[100005], a[100001][15];

int main()
{
    int n, m, q;
    S(n), S(m);
    S(q);
    int i, j, x, y;
    fori(i, 0, n) {
        fori(j, 0, m) {
            S(a[i][j]);
        }
    }
    fori(i,0,q) {
        S(x), S(y);
        x--, y--;
        lo[x]--;
        up[y]++;
    }
    fori(i, 0, m) {
        fori(j, 0, n) {
            if(a[j][i]) lo[j] += up[i];
        }
    }
    fori(i,0,n) {
        cout << lo[i] << " ";
    }
    cout << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <cstdlib>
#include <string>
#include <list>
#include <bitset>
#include <iomanip>
#include <cmath>
#include <sstream>
#include <deque>
#include <climits>
#include <cassert>

using namespace std;

#define ull unsigned long long
#define ll long long
#define Max(x,y) ((x)>(y)?(x):(y))
#define Min(x,y) ((x)<(y)?(x):(y))
#define Sl(x) scanf("%lld",&x)
#define Su(x) scanf("%llu",&x)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define S(x) scanf("%d",&x)
#define IS(x) cin>>x
#define ISF(x) getline(cin,x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define pps pair<ll,pll>
#define ppf pair<pll,ll>
#define psi pair<string,int>
#define pis pair<int,string>
#define fr first
#define se second
#define p(x) cout<<(x)
#define MOD 1000000007
#define eps 1e-7
#define V(x) vector<x>
#define pb(x) push_back(x)
#define mem(x,i) memset(x,i,sizeof(x))
#define fori(i,s,n) for(i=(s);i<(n);i++)
#define ford(i,s,n) for(i=(n);i>=(s);--i)
#define INF 8944674407370955161LL
#define debug(i,st,arr) fori(i,0,st){cout<<arr[i]<<" ";}cout<<endl;
#define forci(i,sw) for((i)=(sw).begin();(i)!=(sw).end();(i)++)
#define forcd(i,sw) for((i)=(sw).rbegin();(i)!=(sw).rend();(i)++)

int abs(int x) {if(x < 0) return -x; return x;}

int up[100005], lo[100005], a[1001][1001];

int main()
{
    int n, m, q;
    S(n), S(m);
    S(q);
    int i, j, x, y;
    fori(i, 0, n) {
        fori(j, 0, m) {
            S(a[i][j]);
        }
    }
    fori(i,0,q) {
        S(x), S(y);
        x--, y--;
        lo[x]--;
        up[y]++;
    }
    fori(i, 0, m) {
        fori(j, 0, n) {
            if(a[j][i]) lo[j] += up[i];
        }
    }
    fori(i,0,n) {
        cout << lo[i] << " ";
    }
    cout << endl;
    return 0;
}


#include    <iostream>
#include    <algorithm>
#include    <cstdio>

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FOR_(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define _FOR(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)

#define PI 3.14159265358979323846
#define LL long long
#define NM 20001

using namespace std;

int n, m, k, room[11][NM], num[11], notice[NM];

int main() {

    ios::sync_with_stdio(0);
    cin >>n >>m >>k;
    int x, y;
    FOR_(i, 1, n) {
        FOR_(j, 1, m) {
            cin >>x;
            if (x) room[j][num[j]++] = i;
        }
    }
    FOR(i, 0, k) {
        cin >>x >>y;
        FOR(j, 0, num[y])
            if (room[y][j] != x) notice[room[y][j]]++;
    }
    FOR_(i, 1, n) printf("%d ", notice[i]);
    return 0;

}


#include    <iostream>
#include    <algorithm>

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FOR_(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define _FOR(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)

#define PI 3.14159265358979323846
#define LL long long
#define NM 20001

using namespace std;

int n, m, k, in[NM][11], notice[NM], notRoom[NM];

int main() {

    ios::sync_with_stdio(0);
    cin >>n >>m >>k;
    int x, y;
    FOR_(i, 1, n) {
        FOR_(j, 1, m) {
            cin >>in[i][j];
        }
    }
    FOR(i, 0, k) {
        cin >>x >>y;
        notice[x]--;
        notRoom[y]++;
    }
    FOR_(i, 1, n)
        FOR_(j, 1, m) notice[i] += notRoom[j] * in[i][j];
    FOR_(i, 1, n) cout <<notice[i] <<" ";
    return 0;

}


#include    <iostream>
#include    <algorithm>

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FOR_(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define _FOR(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)

#define PI 3.14159265358979323846
#define LL long long
#define NM 20001

using namespace std;

int n, m, k, room[11][NM], num[11], notice[NM];

int main() {

    ios::sync_with_stdio(0);
    cin >>n >>m >>k;
    int x, y;
    FOR_(i, 1, n) {
        FOR_(j, 1, m) {
            cin >>x;
            if (x) room[j][num[j]++] = i;
        }
    }
    FOR(i, 0, k) {
        cin >>x >>y;
        FOR(j, 0, num[y])
            if (room[y][j] != x) notice[room[y][j]]++;
    }
    FOR_(i, 1, n) cout <<notice[i] <<" ";
    return 0;

}


/*
  pilosofi template c++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <conio.h>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 1000000000000000009

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int chat[22222][2222];
int ans[22222];
int main(){
	#ifdef PILOSOFI
		freopen("input.txt","r",stdin);
	#endif
	int n,m,k;
	scanf("%d %d %d", &n,&m,&k);
	FOR(i,1,n){
        FOR(j,1,m){
            scanf("%d", &chat[i][j]);
        }
	}

	RESET(ans,0);
	REP(i,k){
        int x ,y;
        scanf("%d %d", &x , &y);
        FOR(j,1,n){
            if(j == x) continue;
            if(chat[j][y] == 1){
                ans[j]++;
            }
        }
	}
	FOR(i,1,n){
        printf("%d ", ans[i]);
	}
    return 0;
}


/*
  pilosofi template c++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <conio.h>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 1000000000000000009

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int chat[22222][12], mat[22222][12] = {0};
int ans[22222] = {0},temp1[12] = {0};
int main(){
	#ifdef PILOSOFI
		freopen("input.txt","r",stdin);
	#endif
	int n,m,k;
	scanf("%d %d %d", &n,&m,&k);
	//200000
	FOR(i,1,n){
        FOR(j,1,m){
            scanf("%d", &chat[i][j]);
        }
	}
	//200000
	REP(i,k){
        int x ,y;
        scanf("%d %d", &x , &y);
        mat[x][y]++;
        temp1[y]++;
	}
	//200000
	FOR(i,1,n){
        FOR(j,1,m){
            if(chat[i][j] == 1){
                ans[i] += temp1[j] - mat[i][j];
            }
        }
	}
	//20000
	FOR(i,1,n){
        printf("%d ", ans[i]);
	}

    return 0;
}


/*
  pilosofi template c++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <conio.h>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 1000000000000000009

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int chat[2222][2222];
int main(){
	#ifdef PILOSOFI
		freopen("input.txt","r",stdin);
	#endif
	int n,m,k;

	scanf("%d %d %d", &n,&m,&k);

	FOR(i,1,n){
        FOR(j,1,m){
            scanf("%d", &chat[i][j]);
        }
	}
	int ans[2222];
	RESET(ans,0);
	REP(i,k){
        int x ,y;
        scanf("%d %d", &x , &y);
        FOR(j,1,n){
            if(j == x) continue;
            if(chat[j][y] == 1){
                ans[j]++;
            }
        }
	}
	FOR(i,1,n){
        printf("%d ", ans[i]);
	}
    return 0;
}


/*
  pilosofi template c++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <conio.h>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 1000000000000000009

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int chat[22222][12], mat[12][22222] = {0};
int ans[22222] = {0},temp1[12] = {0};
int main(){
	#ifdef PILOSOFI
		freopen("input.txt","r",stdin);
	#endif
	int n,m,k;
	scanf("%d %d %d", &n,&m,&k);
	//200000
	FOR(i,1,n){
        FOR(j,1,m){
            scanf("%d", &chat[i][j]);
        }
	}
	//200000
	REP(i,k){
        int x ,y;
        scanf("%d %d", &x , &y);
        mat[x][y]++;
        temp1[y]++;
	}
	//200000
	FOR(i,1,n){
        FOR(j,1,m){
            if(chat[i][j] == 1){
                ans[i] += temp1[j] - mat[i][j];
            }
        }
	}
	//20000
	FOR(i,1,n){
        printf("%d ", ans[i]);
	}

    return 0;
}


/*
  pilosofi template c++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <conio.h>

#define REP(X, Y) for (int (X) = 0; (X) < (Y); ++(X))
#define FOR(X, Y, Z) for (int (X) = (Y); (X) <= (Z); ++(X))
#define RFOR(X, Y, Z) for (int (X) = (Y); (X) >= (Z); --(X))
#define SZ(Z) ((int)(Z).size())
#define ALL(W) (W).begin(), (W).end()
#define RESET(C, V) memset(C, V, sizeof(C))
#define PB push_back
#define MP make_pair
#define A first
#define B second
#define MX(Z, Y) Z = max((Z), (Y))
#define MN(X, Y) X = min((X), (Y))
#define FORIT(X, Y) for(typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); X++)
#define RFORIT(X, Y) for(typeof((Y).rbegin()) X = (Y).rbegin(); X != (Y).rend(); X++)
#define INTINF 2147483647
#define LLINF 1000000000000000009

#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))   // returns S % N, where N is a power of 2
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int chat[2222][2222];
int ans[2222];
int main(){
	#ifdef PILOSOFI
		freopen("input.txt","r",stdin);
	#endif
	int n,m,k;
	scanf("%d %d %d", &n,&m,&k);
	FOR(i,1,n){
        FOR(j,1,m){
            scanf("%d", &chat[i][j]);
        }
	}

	RESET(ans,0);
	REP(i,k){
        int x ,y;
        scanf("%d %d", &x , &y);
        FOR(j,1,n){
            if(j == x) continue;
            if(chat[j][y] == 1){
                ans[j]++;
            }
        }
	}
	FOR(i,1,n){
        printf("%d ", ans[i]);
	}
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

long long int ansTable[MAXM];
long long int chatTable[MAXM][MAXM];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

using namespace std;

#define MAXN 25000
#define MAXM 10
#define MAXK 250000

int ansTable[MAXN];
int chatTable[MAXN][MAXM];

int x, y;
int n , m , k;
int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
                cin >> chatTable[i][j];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[i][y])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << endl;
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

long long int ansTable[MAXN];
long long int chatTable[MAXM][MAXN];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 10
#define MAXK 250000

using namespace std;

long long int ansTable[MAXN];
long long int chatTable[MAXN][MAXM];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 10
#define MAXK 250000

using namespace std;

long long int ansTable[MAXN];
long long int chatTable[MAXM][MAXN];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

long long int ansTable[MAXM];
long long int chatTable[MAXM][MAXN];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>
#include <set>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

set<long long int> chatTable[MAXN];
long long int ansTable[MAXN];

long long int x, y;
long long int n , m , k;
long long int i, j;
long long int tmp;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++){
            cin >> tmp;
            if(tmp)
                chatTable[j].insert(i);
    }

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(set<long long int>::iterator iter = chatTable[y].begin(); iter != chatTable[y].end(); iter++){
                    ansTable[*iter]++;
        }
        ansTable[x]--;
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 10
#define MAXK 250000

using namespace std;

long long int ansTable[MAXK];
long long int chatTable[MAXN][MAXM];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

int ans[MAXN], record[MAXN];
int chatTable[MAXM][MAXN];

int x, y;
int n , m , k;
int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        ans[x]--;
        record[y]++;
    }
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            if(chatTable[j][i])
                ans[i] += record[j];

    for(i = 1; i < n; i++)
        cout << ans[i] << " ";
    cout << ans[i] << "\n";
    return 0;
}


#include <iostream>

#define MAXN 25000
#define MAXM 15
#define MAXK 250000

using namespace std;

long long int ansTable[MAXN];
long long int chatTable[MAXN][MAXN];

long long int x, y;
long long int n , m , k;
long long int i, j;

int main()
{
    cin >> n >> m >> k;
    for(i = 1; i <= n ; i++)
        for(j = 1; j <= m; j++)
            cin >> chatTable[j][i];

    for(j = 1; j <= k; j++){
        cin >> x >> y;
        for(i = 1; i <= n; i++){
            if(i != x && chatTable[y][i])
                ansTable[i]++;
        }
    }
    for(i = 1; i < n ; i++)
        cout << ansTable[i] << " ";
    cout << ansTable[i] << "\n";
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

using namespace std;

int main(void){
	int m,n,k;
	bool chat[20005][11];
	int v[20005];
	scanf(" %d %d %d\n",&n,&m,&k);
	memset(chat,false,sizeof chat);
	memset(v,0,sizeof v);
	int a,b;
	for (int i = 0;i < n;i++)
		for (int j = 0;j < m; j++){
			scanf(" %d",&a);
			if (1 == a) chat[i][j] = true;
		}
	for (int i = 0;i < k;i++){
		scanf(" %d %d\n",&a,&b);
		for (int i = 0;i < n; i++)
			if ((chat[i][(b-1)])&&(i != (a-1))) v[i]++;
	}
	printf("%d",v[0]);
	for (int i = 1;i < n; i++) printf(" %d",v[i]);
	printf("\n");
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<map>

using namespace std;
typedef pair<int,int> ii;

int main(void){
	int m,n,k;
	bool chat[20005][11];
	map<int,int> mp;
	int v[20005];
	vector<ii> s;
	scanf(" %d %d %d\n",&n,&m,&k);
	memset(chat,false,sizeof chat);
	memset(v,0,sizeof v);
	int a,b;
	for (int i = 0;i < n;i++)
		for (int j = 0;j < m; j++){
			scanf(" %d",&a);
			if (1 == a) chat[i][j] = true;
		}
	for (int i = 0;i < k;i++){
		scanf(" %d %d\n",&a,&b);
		s.push_back(make_pair((a-1),(b-1)));
		mp[(b-1)]++;
	}

	map<int,int>::iterator it;
	for (it = mp.begin(); it != mp.end(); it++){
		for (int i = 0;i < n; i++){
			if (chat[i][it->first]){
				 v[i] += it->second;
			}
		}
	}
	for (int i = 0; i < s.size(); i++) v[s[i].first]--;

	printf("%d",v[0]);
	for (int i = 1;i < n; i++) printf(" %d",v[i]);
	printf("\n");
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>

using namespace std;

int main(void){
	int m,n,k;
	bool chat[2005][11];
	int v[2005];
	scanf(" %d %d %d\n",&n,&m,&k);
	memset(chat,false,sizeof chat);
	memset(v,0,sizeof v);
	int a,b;
	for (int i = 0;i < n;i++)
		for (int j = 0;j < m; j++){
			scanf(" %d",&a);
			if (1 == a) chat[i][j] = true;
		}
	for (int i = 0;i < k;i++){
		scanf(" %d %d\n",&a,&b);
		for (int i = 0;i < n; i++)
			if ((chat[i][(b-1)])&&(i != (a-1))) v[i]++;
	}
	printf("%d",v[0]);
	for (int i = 1;i < n; i++) printf(" %d",v[i]);
	printf("\n");
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define P(x) printf("%d ",x)
int a[20000][11];
typedef long long int LL;
int main() {
	int n,m,k;
	S(n);
	S(m);
	S(k);
	rep(i,0,n)
        rep(j,0,m)
            S(a[i][j]);
    int x,y;
    rep(i,0,n)
        a[i][10]=0;
    rep(i,0,k) {
        S(x);
        S(y);
        rep(j,0,n)  {
           if(a[j][y-1] == 1)
                a[j][10]+=1;
        }
        a[x-1][10]-=1;
    }
    rep(i,0,n)
        P(a[i][10]);
	return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define P(x) printf("%d ",x)
int a[20000][11];
typedef long long int LL;
int main() {
    int n,m,k;
    S(n);
    S(m);
    S(k);
    rep(i,0,n)
        rep(j,0,m)
            S(a[i][j]);
    int x,y;
    rep(i,0,k) {
        S(x);
        S(y);
        rep(j,0,n)  {
           if(a[j][y-1] == 1)
                a[j][10]+=1;
        }
        a[x-1][10]-=1;
    }
    rep(i,0,n)
        P(a[i][10]);
    return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define P(x) printf("%d ",x)
int a[20000][11];
typedef long long int LL;
void F(int &x) {
register int c=getchar_unlocked();
for(;c<48||c>57;c=getchar_unlocked());
for(x=0;c>47&&c<58;c=getchar_unlocked()) x=(x<<1)+(x<<3)+c-48;
}
int main() {
    int n,m,k;
    F(n);
    F(m);
    F(k);
    rep(i,0,n)
        rep(j,0,m)
            F(a[i][j]);
    int x,y;
    rep(i,0,k) {
        F(x);
        F(y);
        rep(j,0,n)  {
           if(a[j][y-1] == 1)
                a[j][10]+=1;
        }
        a[x-1][10]-=1;
    }
    rep(i,0,n)
        P(a[i][10]);
    return 0;
}


#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define P(x) printf("%d ",x)
int a[20001][11];
typedef long long int LL;
int main() {
    int n,m,k;
    S(n);
    S(m);
    S(k);
    rep(i,0,n)
        rep(j,0,m)
            S(a[i][j]);
    int x,y;
    rep(i,0,k) {
        S(x);
        S(y);
        a[20000][y-1]+=1;
        a[x-1][10]-=1;
    }
    rep(i,0,m)
        rep(j,0,n)
            if(a[j][i] == 1)
                a[j][10]+=a[20000][i];
    rep(i,0,n)
        P(a[i][10]);
    return 0;
}


#include <iostream>
using namespace std;
bool ok[20010][11];
int num[20010];
int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>ok[i][j];
	while(k--)
	{
		int a,b;
		cin>>a>>b;
		for(int i=1;i<=n;i++)
			if(i!=a&&ok[i][b])
				num[i]++;
	}
	for(int i=1;i<=n;i++)
		cout<<num[i]<<" ";
	return 0;

}


#include <cstdio>
using namespace std;
bool ok[20010][11];
int num[20010];
int sum[11];
int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int a;
			scanf("%d",&a);
			ok[i][j]=a;
		}
	while(k--)
	{
		int a,b;
		scanf("%d %d",&a,&b);
		sum[b]++;
		num[a]--;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			if(ok[i][j])
				num[i]+=sum[j];
		printf("%d ",num[i]);
	}
	return 0;

}


#include <cstdio>
using namespace std;
bool ok[20010][11];
int num[20010];
int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			int a;
			scanf("%d",&a);
			ok[i][j]=a;
		}
	while(k--)
	{
		int a,b;
		scanf("%d %d",&a,&b);;
		for(int i=1;i<=n;i++)
			if(i!=a&&ok[i][b])
				num[i]++;
	}
	for(int i=1;i<=n;i++)
		printf("%d ",num[i]);
	return 0;

}


#include <iostream>
#include <map>
#include <vector>
#include <cstdio>
using namespace std;

int main(int argc, char const *argv[])
{
    //while(1)
    {
        int n, m, k;
        //employees, chats, logEvents
        cin >> n >> m >> k;
        std::vector<int> messageSentToChat(m, 0);
        std::vector<int> chatForEmployee[n];
        std::vector<int> megsSentByEmployee(n, 0);
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                int tmp;
                cin >> tmp;
                if(tmp)
                    chatForEmployee[i].push_back(j);
            }

        for(int i=0;i<k;i++){
            int employee, chatNum;
            cin >> employee >> chatNum;
            employee--;chatNum--;
            messageSentToChat[chatNum]++;
            megsSentByEmployee[employee]++;
        }
        for(int i=0;i<n;i++){
            int sum = 0;
            for(int j=0;j<chatForEmployee[i].size();j++){
                sum += messageSentToChat[chatForEmployee[i][j]];
            }
            cout << (sum - megsSentByEmployee[i]) << " ";
        }
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <map>
#include <vector>
#include <cstdio>
using namespace std;

int main(int argc, char const *argv[])
{
    //while(1)
    {
        int n, m, k;
        //employees, chats, logEvents
        cin >> n >> m >> k;
        vector<int> notif (n, 0);
        vector<int> chats[m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                int tmp;
                cin >> tmp;
                if(tmp)
                    chats[j].push_back(i);
            }

        for(int i=0;i<k;i++){
            //read logs
            int employee, chatNum;
            scanf("%d %d",&employee, &chatNum);
            employee--;
            chatNum--;
            for(int i=0;i<chats[chatNum].size();i++){
                if(chats[chatNum][i] != employee)
                    notif[chats[chatNum][i]]++;
            }
            /*cout << "Now the notif[] = ";
            for(int i=0;i<n;i++)cout << notif[i] << " ";
            cout << endl;*/
        }
        for(int i=0;i<n;i++)cout << notif[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
    //while(1)
    {
        int n, m, k;
        //employees, chats, logEvents
        cin >> n >> m >> k;
        vector<int> notif (n, 0);
        vector<int> chats[m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++){
                int tmp;
                cin >> tmp;
                if(tmp)
                    chats[j].push_back(i);
            }

        for(int i=0;i<k;i++){
            //read logs
            int employee, chatNum;
            cin >> employee >> chatNum;
            employee--;
            chatNum--;
            for(int i=0;i<chats[chatNum].size();i++){
                if(chats[chatNum][i] != employee)
                    notif[chats[chatNum][i]]++;
            }
            /*cout << "Now the notif[] = ";
            for(int i=0;i<n;i++)cout << notif[i] << " ";
            cout << endl;*/
        }
        for(int i=0;i<n;i++)cout << notif[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
   // while(1)
    {
        int n, m, k;
        //employees, chats, logEvents
        cin >> n >> m >> k;
        vector<int> notif (n, 0);
        int chats[n][m];
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                cin >> chats[i][j];

        for(int i=0;i<k;i++){
            //read logs
            int employee, chatNum;
            cin >> employee >> chatNum;
            employee--;
            chatNum--;
            for(int i=0;i<n;i++){
                if(i != employee && chats[i][chatNum] == 1){
                    notif[i]++;
                }
            }
            /*cout << "Now the notif[] = ";
            for(int i=0;i<n;i++)cout << notif[i] << " ";
            cout << endl;*/
        }
        for(int i=0;i<n;i++)cout << notif[i] << " ";
        cout << endl;
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	freopen("B.in", "r", stdin);
	int n, m, k; cin>>n>>m>>k;
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[m][n]; memset(E, 0, sizeof(E));
	int U[m]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; scanf("%d", &tmp_val);
			if(tmp_val)
				E[j][U[j]++] = i;
		}

	int V[n]; memset(V, 0, sizeof(V));
	for(int i = 0; i < k; i++){
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		for(int j = 0; j < U[y]; j++){
			if(E[y][j] != x)
				V[E[y][j]] ++;
		}
	}
	for(int i = 0; i < n; i++)
		cout << V[i] << ' ';
	cout << endl;
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	//freopen("B.in", "r", stdin);
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[n][m]; memset(E, 0, sizeof(E));
	int U[n]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; scanf("%d", &tmp_val);
			if(tmp_val)
				E[i][U[i]++] = j;
		}

	/*
	for(int i = 0; i < n; i++){
		for(int j = 0; j < U[i]; j++)
			cout << E[i][j] << ' ';
		cout << endl;
	}
	*/

	int V[n]; memset(V, 0, sizeof(V));
	int Visited[m]; memset(Visited, 0, sizeof(Visited));
	int Used[n][m]; memset(Used, 0, sizeof(Used));

	for(int i = 0; i < k; i++){
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		Used[x][y] ++;
		Visited[y] ++;
	}
	for(int i = 0; i < n; i++){
		int tmp_sum = 0;
		for(int j = 0; j < U[i]; j++)
			tmp_sum += (Visited[E[i][j]] - Used[i][E[i][j]]);
		printf("%d ", tmp_sum);
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	//freopen("B.in", "r", stdin);
	int n, m, k; cin>>n>>m>>k;
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[m][n]; memset(E, 0, sizeof(E));
	int U[m]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; cin>>tmp_val;
			if(tmp_val)
				E[j][U[j]++] = i;
		}

	int V[n]; memset(V, 0, sizeof(V));
	for(int i = 0; i < k; i++){
		int x, y; cin>>x>>y;
		x--, y--;
		for(int j = 0; j < U[y]; j++){
			if(E[y][j] != x)
				V[E[y][j]] ++;
		}
	}
	for(int i = 0; i < n; i++)
		cout << V[i] << ' ';
	cout << endl;
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	freopen("B.in", "r", stdin);
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[n][m]; memset(E, 0, sizeof(E));
	int U[n]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; scanf("%d", &tmp_val);
			if(tmp_val)
				E[i][U[i]++] = j;
		}

	/*
	for(int i = 0; i < n; i++){
		for(int j = 0; j < U[i]; j++)
			cout << E[i][j] << ' ';
		cout << endl;
	}
	*/

	int V[n]; memset(V, 0, sizeof(V));
	int Visited[m]; memset(Visited, 0, sizeof(Visited));
	int Used[n][m]; memset(Used, 0, sizeof(Used));

	for(int i = 0; i < k; i++){
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		Used[x][y] ++;
		Visited[y] ++;
	}
	for(int i = 0; i < n; i++){
		int tmp_sum = 0;
		for(int j = 0; j < U[i]; j++)
			tmp_sum += (Visited[E[i][j]] - Used[i][E[i][j]]);
		printf("%d ", tmp_sum);
	}
	printf("\n");
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	//freopen("B.in", "r", stdin);
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[m][n]; memset(E, 0, sizeof(E));
	int U[m]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; scanf("%d", &tmp_val);
			if(tmp_val)
				E[j][U[j]++] = i;
		}

	int V[n]; memset(V, 0, sizeof(V));
	for(int i = 0; i < k; i++){
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		for(int j = 0; j < U[y]; j++){
			if(E[y][j] != x)
				V[E[y][j]] ++;
		}
	}
	for(int i = 0; i < n; i++)
		printf("%d ",V[i]);
	printf("\n");
	return 0;
}


#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;

int main(){
	//freopen("B.in", "r", stdin);
	int n, m, k; cin>>n>>m>>k;
	//int mat[n][m]; memset(mat, 0, sizeof(mat));
	int E[m][n]; memset(E, 0, sizeof(E));
	int U[m]; memset(U, 0, sizeof(U));
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++){
			int tmp_val; scanf("%d", &tmp_val);
			if(tmp_val)
				E[j][U[j]++] = i;
		}

	int V[n]; memset(V, 0, sizeof(V));
	for(int i = 0; i < k; i++){
		int x, y; scanf("%d%d", &x, &y);
		x--, y--;
		for(int j = 0; j < U[y]; j++){
			if(E[y][j] != x)
				V[E[y][j]] ++;
		}
	}
	for(int i = 0; i < n; i++)
		cout << V[i] << ' ';
	cout << endl;
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>

using namespace std;

long gcd(long a, long b){

  if(a%b==0) return b;
  else return gcd(b,a%b);

}

long lcm(long a, long b){
  return a*b/gcd(a,b);
}

int main(){
	long n,m,k;
	cin>>n>>m>>k;
	vector< vector<long> > chat(m+1);
	vector<long> res(n,0);
	for(long i=0;i<n;i++){
		for(long j=0;j<m;j++){
			int tmp;
			cin>>tmp;
			if(tmp==1) chat[j+1].push_back(i+1);
		}
	}

	for(long i=0;i<k;i++){
		long x,y;
		cin>>x>>y;

		for(long j=0;j<chat[y].size();j++){
			if(chat[y][j]==x) continue;
			else res[chat[y][j]-1]++;
		}

	}

	for(long i=0;i<res.size();i++) cout<<res[i]<<" ";
	cout<<endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>

using namespace std;

long gcd(long a, long b){

  if(a%b==0) return b;
  else return gcd(b,a%b);

}

long lcm(long a, long b){
  return a*b/gcd(a,b);
}

int main(){
	long n,m,k;
	cin>>n>>m>>k;
	vector< vector<bool> > chat(n+1);
	vector<long> X(n+1,0),Y(m+1,0);
//	vector<long> res(n,0);
	for(long i=1;i<=n;i++){
		chat[i].resize(m+1);
		for(long j=1;j<=m;j++){
			int tmp;
			scanf("%d",&tmp);
			if(tmp==1) chat[i][j]=true;
			else chat[i][j]=false;
		}
	}

	for(long i=0;i<k;i++){
		long x,y;
		scanf("%ld %ld",&x,&y);
		X[x]++; Y[y]++;
	}

	for(long i=1;i<=n;i++){
		long res=0;
		for(int j=1;j<=m;j++) if(chat[i][j]) res+=Y[j];
		cout<<res-X[i]<<" ";
	}
	cout<<endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>

using namespace std;

long gcd(long a, long b){

  if(a%b==0) return b;
  else return gcd(b,a%b);

}

long lcm(long a, long b){
  return a*b/gcd(a,b);
}

int main(){
	long n,m,k;
	cin>>n>>m>>k;
	vector< vector<long> > chat(m+1);
	vector< vector<long> > send(n+1);
	vector<long> res(n,0);
	for(long i=0;i<n;i++){
		send[i]=vector<long>(10,0);
		for(long j=0;j<m;j++){
			int tmp;
			scanf("%d",&tmp);
			if(tmp==1) chat[j+1].push_back(i+1);
		}
	}
	send[n]=vector<long>(10,0);

	for(long i=0;i<k;i++){
		long x,y;
		scanf("%ld %ld",&x,&y);
		send[x][y]++;
	}

	for(int i=1;i<=n;i++){
		for(long j=1;j<=m;j++){
			for(long k=0;k<chat[j].size();k++){
				if(chat[j][k]==i) continue;
				else res[chat[j][k]-1]+=send[i][j];
			}
		}
	}

	for(long i=0;i<res.size();i++) printf("%ld ",res[i]);
	cout<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

inline int inp()
{
    register int noRead=0;
    //register char p=getchar_unlocked();
    register char p=getc(stdin);
    //for(;p<48 || p>57;p=getchar_unlocked());
    for(;p<48 || p>57;p=getc(stdin));
    //while(p>47 && p<58){ noRead = (noRead << 3) + (noRead << 1) + (p - '0');p=getchar_unlocked();}
    while(p>47 && p<58){ noRead = (noRead << 3) + (noRead << 1) + (p - '0');p=getc(stdin);}
    return noRead;
};
vector<pair<int,int> > v;
int a[20007][15];
long long cnt[20006]={0};
int chat[15][20006];
int tot[15]={0};
int main()
{
    int n,m,k;
    n=inp();
    m=inp();
    k=inp();
    memset(chat,0,sizeof(chat));
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) a[i][j]=inp();

    int x,y;
    for(int i=0;i<k;i++)
    {
        x=inp();y=inp();
        v.push_back(make_pair(x,y));chat[y-1][x-1]++;tot[y-1]++;

    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(a[i][j]) {cnt[i+1]+=(tot[j]-chat[j][i]);}
        }
    }
    for(int i=1;i<=n;i++) {cout<<cnt[i]; if(i!=n) printf(" ");}
    printf("\n");
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[n+1][m+1];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) cin>>a[i][j];
    vector<pair<int,int> > v;
    int x,y;
    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        v.push_back(make_pair(x,y));

    }
    int cnt[20006]={0};
    for(int i=0;i<k;i++)
    {  int x=v[i].second-1;
        for(int j=0;j<n;j++)
        {
            if(a[j][x]==1 && j!=v[i].first-1) cnt[j+1]++;
        }
    }
    for(int i=1;i<=n;i++) {cout<<cnt[i]; if(i!=n) printf(" ");}
    printf("\n");
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int a[n+1][m+1];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) cin>>a[i][j];
    vector<pair<int,int> > v;
    int x,y;
    for(int i=0;i<k;i++)
    {
        cin>>x>>y;
        v.push_back(make_pair(x,y));

    }
    int cnt[20006]={0};
    for(int i=0;i<k;i++)
    {  int x=v[i].second-1;
        for(int j=0;j<n;j++)
        {
            if(a[j][x]==1 && j!=v[i].first-1) cnt[j+1]++;
        }
    }
    for(int i=1;i<=n;i++) {cout<<cnt[i]; if(i!=n) printf(" ");}
    printf("\n");
}


//

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>

using namespace std ;

int arr[20001] , x , y;
vector< vector<int> > vec ;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n , m , k ;
    scanf("%d%d%d",&n,&m,&k);

    vec.resize(m);

    for(int i = 0  ; i < n ; ++i)
    {
        for(int j =  0 ; j < m ; ++j)
        {
            scanf("%d",&x) ; if(x) vec[j].push_back(i);
        }
    }

    while(k--)
    {
        scanf("%d%d",&x,&y);
        y-- , x--;
        for(int i = 0 ; i < vec[y].size() ; ++i)
            if(vec[y][i]!=x)
                arr[vec[y][i]]++ ;
    }

    for(int i = 0 ; i < n ; ++i)
        printf("%d ",arr[i]);
}


//

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>

using namespace std ;

int arr[20001] , x , y ;
int arr2[11] ;
bool vis[200001][11] ;
int vis2[11][200001] ;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n , m , k ;
    scanf("%d%d%d",&n,&m,&k);

    for(int i = 0  ; i < n ; ++i)
    {
        for(int j =  0 ; j < m ; ++j)
        {
            scanf("%d",& vis[i][j]) ;
        }
    }

    while(k--)
    {
        scanf("%d%d",&x,&y);
        x-- , y--;
        /*for(int i = 0 ; i < n ; ++i)
            if(vis[i][y]!= 0 && i != x )
                arr[i]++ ;*/

        arr2[y]++ ;
        vis2[y][x]++ ;
    }

    for(int i = 0 ; i < n ; ++i)
    {
        int t = 0 ;
        for(int j = 0 ; j < m ; ++j)
        {
            if(vis[i][j])
            {
                t+=arr2[j] ;
                while(vis2[j][i])
                    t-- , vis2[j][i]-- ;
            }
        }
        printf("%d ",t);
    }

}


//

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>

using namespace std ;

int arr[20001] , x , y ;
int arr2[11] ;
bool vis[200001][11] , vis2[11][200001] ;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n , m , k ;
    scanf("%d%d%d",&n,&m,&k);

    for(int i = 0  ; i < n ; ++i)
    {
        for(int j =  0 ; j < m ; ++j)
        {
            scanf("%d",& vis[i][j]) ;
        }
    }

    while(k--)
    {
        scanf("%d%d",&x,&y);
        x-- , y--;
        /*for(int i = 0 ; i < n ; ++i)
            if(vis[i][y]!= 0 && i != x )
                arr[i]++ ;*/

        arr2[y]++ ;
        vis2[y][x] = true ;
    }

    for(int i = 0 ; i < n ; ++i)
    {
        int t = 0 ;
        for(int j = 0 ; j < m ; ++j)
        {
            if(vis[i][j])
            {
                t+=arr2[j] ;
                if(vis2[j][i])
                    t-- ;
            }
        }
        printf("%d ",t);
    }

}


//

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <ctime>
#include <bitset>
#include <numeric>
#include <complex>

using namespace std ;

int arr[20001] , x , y , vis[20001][11];
vector< vector<int> > vec ;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    int n , m , k ;
    scanf("%d%d%d",&n,&m,&k);

    for(int i = 0  ; i < n ; ++i)
    {
        for(int j =  0 ; j < m ; ++j)
        {
            scanf("%d",& vis[i][j]) ;
        }
    }

    while(k--)
    {
        scanf("%d%d",&x,&y);
        y-- , x--;
        for(int i = 0 ; i < n ; ++i)
            if(vis[i][y]!= 0 && i != x )
                arr[i]++ ;
    }

    for(int i = 0 ; i < n ; ++i)
        printf("%d ",arr[i]);
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <complex>
#include <iterator>
#include <fstream>
#include <string>
#include <string.h>
#include <cstring>
using namespace std;
using namespace __gnu_cxx;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define sab(i,n) for(int i = 0; i < (n); i++)
typedef vector<int>vec ;

const double EPS = 1e-6;
const int INF = 1<<28;
const long long INFL = 1LL<<62;
///************************

int arr[20001] ={0};
int main ()
{
int n , m , k ,num , x,y;

scanf("%d %d %d" , &n ,&m ,&k);
vector< vector<int> > all(m);
for(int i=1 ; i<=n ;i++)
{
	for(int j=0 ; j<m ; j++)
	{
		scanf("%d" ,&num);
		if(num==1)
		{
		   all[j].push_back(i);
		}
	}
}
for(int i=0 ; i<k ;i++)
{
	scanf("%d %d" , &x ,&y);
	for(int t=0 ; t< all[y-1].size() ;t++)
	{
		if(all[y-1][t]!=x)
		{
			arr[all[y-1][t]]++ ;
		}
	}
}

for(int i=1 ; i<=n ;i++) printf("%d ",arr[i]);

 return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <complex>
#include <iterator>
#include <fstream>
#include <string>
#include <string.h>
#include <cstring>
using namespace std;
using namespace __gnu_cxx;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define sab(i,n) for(int i = 0; i < (n); i++)
typedef vector<int>vec ;

const double EPS = 1e-6;
const int INF = 1<<28;
const long long INFL = 1LL<<62;
///************************

int arr[20001] ={0};
int arrm[11]={0};
int main ()
{
int n , m , k ,num , x,y;

scanf("%d %d %d" , &n ,&m ,&k);
vector< vector<int> > all(n , vector<int>(m));
for(int i=0 ; i<n ;i++)
{
	for(int j=0 ; j<m ; j++)
	{
		scanf("%d" ,&num);
        all[i][j]=num ;
	}
}

for(int i=0 ; i<k ;i++)
{
	scanf("%d %d" , &x ,&y);

			arr[x-1]--;
			arrm[y-1]++;

}

for(int i=0 ; i<n ;i++)
{
	for(int j=0 ; j<m ; j++)
	{
       if(all[i][j]==1)
       {
       	arr[i]+=arrm[j] ;
       }
	}

}
for(int i=0 ; i<n ;i++)
{
	if(arr[i]<0)  printf("0 ");
	 else printf("%d ",arr[i]);
}

 return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <complex>
#include <iterator>
#include <fstream>
#include <string>
#include <string.h>
#include <cstring>
using namespace std;
using namespace __gnu_cxx;

#define SZ(X) (int)(X).size()
#define ALL(X) (X).begin(),(X).end()
#define ALLR(X) (X).rbegin(),(X).rend()
#define sab(i,n) for(int i = 0; i < (n); i++)
typedef vector<int>vec ;

const double EPS = 1e-6;
const int INF = 1<<28;
const long long INFL = 1LL<<62;
///************************

int arr[20001] ={0};
int all[20001][10]={0};
int arrm[11]={0};
int main ()
{
int n , m , k ,num , x,y;

scanf("%d %d %d" , &n ,&m ,&k);
for(int i=0 ; i<n ;i++)
{
	for(int j=0 ; j<m ; j++)
	{
		scanf("%d" ,&num);
        all[i][j]=num ;
	}
}

for(int i=0 ; i<k ;i++)
{
	scanf("%d %d" , &x ,&y);
			arr[x-1]--;
			arrm[y-1]++;

}

for(int i=0 ; i<n ;i++)
{
	for(int j=0 ; j<m ; j++)
	{
       if(all[i][j]==1)
       {
       	arr[i]+=arrm[j] ;
       }
	}

}
for(int i=0 ; i<n ;i++)
{
	if(arr[i]<0)  printf("0 ");
	 else printf("%d ",arr[i]);
}

 return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define DEBUG(x) { printf << #x << " = " << x << endl; }
#define DEBUGARR(a,n) {cout << #a << " = " ; FOR(_,1,n) cout << a[_] << ' '; cout <<endl;}
#define CHECK printf("OK\n");
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;

int n, m, k, x, y, f[22222];
vector <int> v[20];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("input.txt","r",stdin);
    cin >> n >> m >> k;
    scanf("%d%d%d", &n, &m, &k);
    FOR(i,1,n)
    FOR(j,1,m){
        scanf("%d", &x);
        if (x == 1) v[j].push_back(i);
    }
    FOR(i,1,k){
         cin >> x >> y;
         FOR(j,0,v[y].size()-1)
            if (v[y][j] != x) f[v[y][j]]++;
    }
    FOR(i,1,n) printf("%d ", f[i]);
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define DEBUG(x) { printf << #x << " = " << x << endl; }
#define DEBUGARR(a,n) {cout << #a << " = " ; FOR(_,1,n) cout << a[_] << ' '; cout <<endl;}
#define CHECK printf("OK\n");
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;

int n, m, k, x, y, f[22222], t[22];
vector <int> v[22];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("input.txt","r",stdin);
    scanf("%d%d%d", &n, &m, &k);
    FOR(i,1,n)
    FOR(j,1,m){
        scanf("%d", &x);
        if (x == 1) v[j].push_back(i);
    }
    FOR(i,1,k){
         cin >> x >> y;
         t[y]++;
         f[x]--;
    }
    FOR(i,1,m)
    FOR(j,0,v[i].size()-1) f[v[i][j]] = f[v[i][j]] + t[i];
    FOR(i,1,n) printf("%d ", f[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;

	scanf("%d", &n);

	int array[n][2];
	long long int crossing = 0;

	int ind = 0;

	int x, y;

	for(int i = 0; i < n; i++) {
		scanf("%d %d", &y, &x);
		//cout << "Atual: " << x << " " << y << endl;
		for(int j = 0; j < ind; j++) {
			int x1 = x;
			int y1 = y;
			int x2 = array[j][0];
			int y2 = array[j][1];

			if(x1 == x2 || y1 == y2) continue;

		//	cout << "Comparando com: " << x2 << " " << y2 << endl;
			if(x1 > x2) {
				swap(x1, x2);
				swap(y2, y1);
		//		cout << "swap" << endl;
		//		cout << "x2 " << x2 << " y2 " << y2 << endl;
			}

			int deltaX = x2 - x1;
			int deltaY = y2 - y1;
		//	cout << "deltaY: " << y2 << " - " << y1 << endl;
                //      cout << "deltas: " << deltaY << " / " << deltaX << endl;
			if(deltaX == 0 || deltaY == 0) continue;

			float m = ((float) deltaY) / deltaX;
		//	cout << "m " << m << endl;
			if(m == 1 || m == -1){
			       	crossing++;
			}
		}

		//cout << endl;

		array[i][0] = x;
		array[i][1] = y;
		ind++;
	}

	printf("%lld\n", crossing);
}


#include <bits/stdc++.h>

#define MAX 1000

using namespace std;

int matriz[MAX][MAX];

int main() {
	int n;

	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		matriz[a-1][b-1] = 1;
	}

	long long int resp = 0;
	long long it = 0;
	for(int k = 1; k < MAX + (MAX - 2); k++) {
		int i = max(0, k - MAX + 1);
		int j = -(min(1, MAX - k) - 1);
		long int crossing = 0;
		while(k - j >= 0 and i < MAX) {
			it++;
			//cout <<  i << " " << k - j << endl;
			if(matriz[i][k - j] == 1) crossing++;
			i++;
			j++;
		}

		if(crossing > 1) resp += crossing;
	}

	cout << "1 it: " << it << endl;
//	it = 0;
	for(int k = MAX - 2; k >= -(MAX - 2); k--) {
		int i = max(0, k - MAX);
		int j = 0;
		if(k <= 0){
			i = abs(k);
		       	j -= k;
		}
		long int crossing = 0;
		while(k + j < MAX and i < MAX) {
			//cout << i << " " << k + j << endl;
			if(matriz[i][k+j] == 1) crossing++;
			i++;
			j++;
//			it++;
		}
		if(crossing > 1) resp += crossing;
	}

//	cout << "2 it " << it << endl;

	cout << resp << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;

	scanf("%d", &n);

	int array[n][2];
	long long int crossing = 0;

	int ind = 0;

	int x, y;

	for(int i = 0; i < n; i++) {
		scanf("%d %d", &y, &x);
		//cout << "Atual: " << x << " " << y << endl;
		for(int j = 0; j < ind; j++) {
			int x1 = x;
			int y1 = y;
			int x2 = array[j][0];
			int y2 = array[j][1];

		//	cout << "Comparando com: " << x2 << " " << y2 << endl;
			if(x1 > x2) {
				swap(x1, x2);
				swap(y2, y1);
		//		cout << "swap" << endl;
		//		cout << "x2 " << x2 << " y2 " << y2 << endl;
			}

			int deltaX = x2 - x1;
			int deltaY = y2 - y1;
		//	cout << "deltaY: " << y2 << " - " << y1 << endl;
                //      cout << "deltas: " << deltaY << " / " << deltaX << endl;
			if(deltaX == 0 || deltaY == 0) continue;

			float m = ((float) deltaY) / deltaX;
		//	cout << "m " << m << endl;
			if(m == 1 || m == -1){
			       	crossing++;
			}
		}

		//cout << endl;

		array[i][0] = x;
		array[i][1] = y;
		ind++;
	}

	printf("%lld\n", crossing);
}


#include <bits/stdc++.h>

#define MAX 1001

using namespace std;

int matriz[MAX][MAX];

int main() {
	int n;

	scanf("%d", &n);

	for(int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		matriz[a][b] = 1;
	}

	long long int resp = 0;

	for(int k = 1; k < MAX + (MAX - 2); k++) {
		int i = max(0, k - MAX + 1);
		int j = -(min(1, MAX - k) - 1);
		int crossing = 0;
		while(k - j >= 0 and i < MAX) {
			//cout <<  i << " " << k - j << endl;
			if(matriz[i][k - j] == 1) crossing++;
			i++;
			j++;
		}

		if(crossing > 1) resp += crossing;
	}

	for(int k = MAX - 2; k >= -(MAX - 2); k--) {
		int i = max(0, k - MAX);
		int j = 0;
		if(k <= 0){
			i = abs(k);
		       	j -= k;
		}
		int crossing = 0;
		while(k + j < MAX and i < MAX) {
			//cout << i << " " << k + j << endl;
			if(matriz[i][k+j] == 1) crossing++;
			i++;
			j++;
		}
		if(crossing > 1) resp += crossing;
	}

	cout << resp << endl;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll n,ans=0;
    cin>>n;
    vector<pair<ll,ll>> v;
    map<ll,ll> m;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        m[a-b]++;
        m[a+b]++;
    }
    for(auto i: m){
        ans+=(i.second)*(i.second-1)/2;
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll n,ans=0;
    cin>>n;
    vector<pair<ll,ll>> v;
    map<ll,ll> m;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        ans+=m[a+b];
        ans+=m[a-b];
        m[a-b]++;
        m[a+b]++;
    }
    // for(auto i: m){
    //     ans+=a[x+y]++;
    //     ans+=b[x-y]++;
    //     ans+=(i.second)*(i.second-1)/2;
    // }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll n,ans=0;
    cin>>n;
    vector<pair<ll,ll>> v;
    map<ll,ll> mp,mn;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        // ans+=mp[a+b];
        // ans+=mn[a-b];
        mn[a-b]++;
        mp[a+b]++;
    }
    for(auto i: mp){
        // ans+=a[x+y]++;
        // ans+=b[x-y]++;
        ans+=(i.second)*(i.second-1)/2;
    // }
    for(auto i: mn){
        ans+=(i.second)*(i.second-1)/2;
    }
    cout<<ans;
    return 0;
}


    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long

    int main(){
        ll n,ans=0;
        cin>>n;
        vector<pair<ll,ll>> v;
        map<ll,ll> mp,mn;
        for(ll i=0;i<n;i++){
            ll a,b;
            cin>>a>>b;
            v.push_back(make_pair(a,b));
            // ans+=mp[a+b];
            // ans+=mn[a-b];
            mn[a-b]++;
            mp[a+b]++;
        }
        for(auto i: mp){
            // ans+=a[x+y]++;
            // ans+=b[x-y]++;
            ans+=(i.second)*(i.second-1)/2;
        }
        for(auto i: mn){
            ans+=(i.second)*(i.second-1)/2;
        }
        cout<<ans;
        return 0;
    }


#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ll n,ans=0;
    cin>>n;
    vector<pair<ll,ll>> v;
    map<ll,ll> mp,mn;
    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
        ans+=mp[a+b];
        ans+=mn[a-b];
        mn[a-b]++;
        mp[a+b]++;
    }
    // for(auto i: m){
    //     ans+=a[x+y]++;
    //     ans+=b[x-y]++;
    //     ans+=(i.second)*(i.second-1)/2;
    // }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
ll mat[1001][1001];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n,i,x,y,k,c=0,l,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        mat[x][y]=1;
    }
    y=1;x=1;
    while(y<=n){
        k=1;l=y;
        while(l<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=2;
    while(x<=n){
        k=x;l=1;
        while(k<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        x++;c=0;
    }
    y=1;x=n;
    while(y<=n){
        k=n;l=y;
        while(l<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=n-1;
    while(x>=1){
        k=x;l=1;
        while(k>=1){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        x--;c=0;
    }
    cout<<sum;
    r0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
bool mat[1005][1005];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n,i,x,y,k,c=0,l,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        mat[x][y]=1;
    }
    y=1;x=1;
    while(y<=1000){
        k=1;l=y;
        while(l<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=2;
    while(x<=1000){
        k=x;l=1;
        while(k<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        x++;c=0;
    }
    y=1;x=1000;
    while(y<=1000){
        k=1000;l=y;
        while(l<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=999;
    while(x>=1){
        k=x;l=1;
        while(k>=1){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        x--;c=0;
    }
    cout<<sum;
    r0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
bool mat[1001][1001];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n,i,x,y,k,c=0,l,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        mat[x][y]=1;
    }
    y=1;x=1;
    while(y<=n){
        k=1;l=y;
        while(l<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=2;
    while(x<=n){
        k=x;l=1;
        while(k<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        x++;c=0;
    }
    y=1;x=n;
    while(y<=n){
        k=n;l=y;
        while(l<=n){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=n-1;
    while(x>=1){
        k=x;l=1;
        while(k>=1){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        x--;c=0;
    }
    cout<<sum;
    r0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
bool mat[1001][1001];
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n,i,x,y,k,c=0,l,sum=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        mat[x][y]=1;
    }
    y=1;x=1;
    while(y<=1000){
        k=1;l=y;
        while(l<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=2;
    while(x<=1000){
        k=x;l=1;
        while(k<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k++;
        }
        sum+=(c*(c-1))/2;
        x++;c=0;
    }
    y=1;x=n;
    while(y<=1000){
        k=n;l=y;
        while(l<=1000){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        y++;c=0;
    }
    y=1;x=n-1;
    while(x>=1){
        k=x;l=1;
        while(k>=1){
            if(mat[k][l]==1){
                c++;
            }
            l++;k--;
        }
        sum+=(c*(c-1))/2;
        x--;c=0;
    }
    cout<<sum;
    r0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
int main(){
    int n,i,j,x,y,k,c=0;
    vector<pii> v;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>x>>y;
        v.pb(mp(x,y));
    }
    for(i=0;i<n;i++){
        for(j=0;j<n;j++){
            if(abs(v[i].f-v[j].f)==abs(v[i].s-v[j].s)&&i!=j){c++;}
        }
    }
    cout<<c/2;
    r0;
}


#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define f first
#define s second
#define pb push_back
#define ll long long
#define mp make_pair
#define r0 return 0
typedef pair<int,int> pii;
typedef pair<ll,ll> lpii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<lpii> vlpii;
int mini(int a,int b){return a<b?a:b;}
ll lmini(ll a,ll b){return a<b?a:b;}
int maxi(int a,int b){return a>b?a:b;}
ll lmaxi(ll a,ll b){return a>b?a:b;}
int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); }
ll lgcd(ll a, ll b){ if(b==0) return a; return gcd(b,a%b); }
int lcm(int a, int b) {return a*(b/gcd(a,b));}
ll llcm(ll a, ll b) {return a*(b/gcd(a,b));}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n,i,x,y,k,c=0,l,sum=0;
    cin>>n;
       map<ll,ll> m;
    for(i=1;i<=n;i++){
        cin>>x>>y;
            m[x+y]++;
            m[x-y]++;
    }
    map<ll,ll>::iterator it;
    for(it=m.begin();it!=m.end();it++){
        sum+=((it->s)*((it->s)-1)/2);
    }
    cout<<sum;
    r0;
}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1200
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[300003] , yy[300003];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a++; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}
	}
	cout<<c/2<<endl;

}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1001
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[300003] , yy[300003];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}
	}
	cout<<c/2<<endl;

}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1000
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[N] , yy[N];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a++; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a < 1000 && a > 0 && b < 1000 && b > 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}
	}
	cout<<c/2<<endl;

}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1200
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[300003] , yy[300003];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}
	}
	cout<<c/2<<endl;

}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1010
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[300003] , yy[300003];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a > 0 && b <= 1000 && b > 0){
			a++; b++;
			if(cor[a][b]==1) {c++;}
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a > 0 && b <= 1000 && b > 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a > 0 && b <= 1000 && b > 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a > 0 && b <= 1000 && b > 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}

	}
	cout<<c/2<<endl;

}


//#include <fsociety>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//end of libraries ;
#define INF 999999999
#define N 1010
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
int n , a , b , cor[N][N] , c , ans , xx[300003] , yy[300003];
int main(){
fcin;
	cin>>n;
	for(int i = 0 ; i < n ; i++){
		cin>>a>>b;
		xx[i] = a; yy[i] = b;
		cor[a][b] = 1;
	}
	for(int i = 0 ; i < n ; i++){
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b++;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a++; b--;
			if(cor[a][b]==1) c++;
		}
		a = xx[i]; b = yy[i];
		while(a <= 1000 && a >= 0 && b <= 1000 && b >= 0){
			a--; b--;
			if(cor[a][b]==1) c++;
		}
	}
	cout<<c/2<<endl;

}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    vector<ll>pl;
    vector<ll>fr(2002);
    ll sum=0;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        if(v[i].first==v[i].second)
        {
            cnt++;
        }
        ll p=v[i].first+v[i].second;
        pl.push_back(p);
         fr[p]++;
        p=0;
    }
    if(cnt>0){
    if(cnt<=2){
        sum+=cnt-1;
    }
   else
    {
       for(int j=1; j<cnt; j++)
        {
            sum+=cnt-j;
        }

    }
    }
    ll cnt2=0;
    set<ll>st;
    vector<bool>vs(2002,false);
    for(int i=0;i<pl.size();i++){
        st.insert(pl[i]);
    }
    for(auto i:st)
    {

        if(vs[i]==false)
        {

            if(fr[i]>1){
            for(int k=1;k<fr[i];k++){
                sum+=fr[i]-k;
            }
            vs[i]=true;
            }
        }

    }

    cout<<sum;
    return 0;
}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    vector<ll>pl;
    vector<ll>fr(2002);
    ll sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        if(v[i].first==v[i].second)
        {
            sum++;
        }
        ll p=v[i].first+v[i].second;
        pl.push_back(p);
        fr[p]++;
        p=0;
    }

    set<ll>st;
    vector<bool>vs(2002,false);
    for(int i=0; i<pl.size(); i++)
    {
        st.insert(pl[i]);
    }
    for(auto i:st)
    {

        if(vs[i]==false)
        {

            if(fr[i]>1)
            {

                sum+=fr[i];
            }
            vs[i]=true;
        }
    }

    cout<<sum;
    return 0;
}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    vector<ll>pl;
    vector<ll>fr(2001);
    ll sum=0;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        if(v[i].first==v[i].second)
        {
            cnt++;
        }
        ll p=v[i].first+v[i].second;
        pl.push_back(p);
         fr[p]++;
        p=0;
    }
    if(cnt>1)
    {
       for(int j=1; j<cnt; j++)
        {
            sum+=cnt-j;
        }

    }
    ll cnt2=0;
    set<ll>st;
    vector<bool>vs(2002,false);
    for(int i=0;i<pl.size();i++){
        st.insert(pl[i]);
    }
    for(auto i:st)
    {

        if(vs[i]==false)
        {

            if(fr[i]>1){
            for(int k=1;k<fr[i];k++){
                sum+=fr[i]-k;
            }
            vs[i]=true;
            }
        }

    }

    cout<<sum;
    return 0;
}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    vector<ll>pl;
    ll sum=0;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        if(v[i].first==v[i].second)
        {
            cnt++;
        }
        ll p=v[i].first+v[i].second;
        pl.push_back(p);
        p=0;
    }
    if(cnt>1)
    {
       for(int j=1; j<cnt; j++)
        {
            sum+=cnt-j;
        }

    }
    ll cnt2=0;
    vector<bool>vs(1001,false);
    for(int i=0; i<n; i++)
    {
        ll x=v[i].first+v[i].second;
        for(int j=0; j<pl.size(); j++)
        {
            if(x==pl[j])cnt2++;
        }
        if(vs[x]==false)
        {
            if(cnt2>1){
            for(int k=1;k<cnt2;k++){
                sum+=cnt2-k;
            }
            vs[x]=true;
            }
        }
        cnt2=0;
    }

    cout<<sum;
    return 0;
}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
 map<ll,ll>add;
 map<ll,ll>sub;
ll sum=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        sum+=add[v[i].first+v[i].second];
        add[v[i].first+v[i].second]++;
        sum+=sub[v[i].first-v[i].second];
        sub[v[i].first-v[i].second]++;

    }

    cout<<sum;

    return 0;
}


#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const long long mod=1e9+7;
const double PI=acos(-1);
int main()
{
    fast
    int n;
    cin>>n;
    vector<pair<int,int>>v(n);
    vector<ll>pl;
    vector<ll>fr(2001);
    ll sum=0;
    ll cnt=0;
    for(int i=0; i<n; i++)
    {
        cin>>v[i].first>>v[i].second;
        if(v[i].first==v[i].second)
        {
            cnt++;
        }
        ll p=v[i].first+v[i].second;
        pl.push_back(p);
         fr[p]++;
        p=0;
    }
    if(cnt>1)
    {
       for(int j=1; j<cnt; j++)
        {
            sum+=cnt-j;
        }

    }
    ll cnt2=0;
    set<ll>st;
    vector<bool>vs(1001,false);
    for(int i=0;i<pl.size();i++){
        st.insert(pl[i]);
    }
    for(auto i:st)
    {

        if(vs[i]==false)
        {

            if(fr[i]>1){
            for(int k=1;k<fr[i];k++){
                sum+=fr[i]-k;
            }
            vs[i]=true;
            }
        }

    }

    cout<<sum;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

bool check[1001][1001];

int main() {
  int n, ans = 0;
  vector < pair<int, int> > seq;
  cin >> n;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    seq.push_back(make_pair(x, y));
  }
  for (int i = 0; i < seq.size(); i++) {
    if (!check[seq[i].first][seq[i].second]) {
      check[seq[i].first][seq[i].second] = true;
      int sum = 1;
      for (int j = 0; j < seq.size(); j++) {
        if (i != j
            && abs(seq[i].first - seq[j].first)
                == abs(seq[i].second - seq[j].second))
          sum++, check[seq[j].first][seq[j].second] = true;
      }
      ans += sum * (sum - 1) / 2;
    }
  }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

bool check[1001][1001];

int main() {
  long long n, ans = 0;
  vector < pair<long long, long long> > seq;
  cin >> n;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    seq.push_back(make_pair(x, y));
  }
  for (int i = 0; i < seq.size(); i++) {
    if (!check[seq[i].first][seq[i].second]) {
      check[seq[i].first][seq[i].second] = true;
      int sum = 1, p = -2;
      for (int j = 0; j < seq.size(); j++) {
        if (i != j
            && abs(seq[i].first - seq[j].first)
                == abs(seq[i].second - seq[j].second)
            && (p == -2
                || p
                    == (seq[i].first - seq[j].first)
                        / (seq[i].second - seq[j].second)))
          sum++, check[seq[j].first][seq[j].second] = true, p = (seq[i].first
              - seq[j].first) / (seq[i].second - seq[j].second);
      }
      ans += sum * (sum - 1) / 2;
    }
  }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

bool check[1001][1001], ex[1001][1001];

int main() {
  int n, ans = 0;
  vector < pair<int, int> > seq;
  cin >> n;
  for (int i = 0, x, y; i < n; i++) {
    cin >> x >> y;
    ex[x][y] = true;
    seq.push_back(make_pair(x, y));
  }
  for (int i = 0; i < seq.size(); i++) {
    if (!check[seq[i].first][seq[i].second]) {
      check[seq[i].first][seq[i].second] = true;
      int sum = 1;
      for (int j = seq[i].first + 1, k = seq[i].second + 1;
          j < 1001 && k < 1001; j++, k++)
        if (ex[j][k])
          sum++, check[j][k] = true;
      for (int j = seq[i].first - 1, k = seq[i].second - 1; j > 0 && k > 0;
          j--, k--)
        if (ex[j][k])
          sum++, check[j][k] = true;
      ans += (sum * (sum - 1)) / 2, sum = 1;
      for (int j = seq[i].first - 1, k = seq[i].second + 1; j > 0 && k < 1001;
          j--, k++)
        if (ex[j][k])
          sum++, check[j][k] = true;
      for (int j = seq[i].first + 1, k = seq[i].second - 1; j < 1001 && k > 0;
          j++, k--)
        if (ex[j][k])
          sum++, check[j][k] = true;
      ans += (sum * (sum - 1)) / 2;
    }
  }
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a -= b;
		ans += m[a++];
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int mxn = 2e5;

int x[mxn + 11];
int y[mxn + 11];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d", x + i, y + i);
	}
	int cnt = 1;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			int a = x[i] - x[j];
			int b = y[i] - y[j];
			if (a < 0)
				a = -a;
			if (b < 0)
				b = -b;
			if (a == b) {
				cnt++;
			}
		}
	}
	int ans = cnt * (cnt - 1) / 2;
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m1;
map <int, int> m2;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		ans += m1[a + b]++;
		ans += m2[a - b]++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		ans += m[a + b]++;
		ans += m[a - b]++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		int c = a + b;
		int d = a - b;
		ans += m[c]++;
		ans += m[d]++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a -= b;
		ans += m[a++];
		cout << a << endl;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;
map <int, int> k;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		int c = a + b;
		int d = a - b;
		ans += m[c]++;
		ans += k[d]++;
	}
	printf("%d\n", ans);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

map <int, int> m;

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		a -= b;
		ans += m[a]++;
	}
	printf("%d\n", ans);
	return 0;
}