#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int,int> pos;
vector<pos> L;
const int N=55;
int S[N][N];
int main(){
int n,l,s,count=0;
scanf("%d%d%d",&n,&l,&s);
int x,y;
for(int i=0;i<n;i++){
scanf("%d%d",&x,&y);
L.push_back(pos(x,y));
}
for(int i=s;i>=0;i--){
for(int j=0;j<=s;j++){
scanf("%d",&S[i][j]);
if(S[i][j]==1)count++;
}
}
int res=0;
for(auto v:L){
bool tag=true;
int x=v.first,y=v.second;
if(max(x,y)+s>l)continue;// 不行,不在考虑内
int one_count=0;
for(auto w:L){
int sx=w.first-x,sy=w.second-y;
if(sx>=0&&sx<=s&&sy>=0&&sy<=s){
// printf("%d %d:A:%d %d\n",x,y,w.first,w.second);
if(S[sx][sy]!=1){
// printf("%d %d:%d %d:%d %d\n",x,y,w.first,w.second,sx,sy);
tag=false;
break;
}else one_count++;
}
}
if(tag&&one_count==count)res++;
}
printf("%d\n",res);
}