import java.util.Scanner;
class Main {
static class Point {
int x, y;
Point(int x, int y) {
this.x = x;
this.y = y;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt(); // 树木的数量
int l = sc.nextInt(); // 地图的大小
int s = sc.nextInt(); // 藏宝图的大小
Point[] tree = new Point[n]; // 存储树木的坐标
for (int i = 0; i < n; ++i) {
int x = sc.nextInt();
int y = sc.nextInt();
tree[i] = new Point(x, y);
}
int[][] pic = new int[s + 1][s + 1]; // 藏宝图
for (int i = s; i >= 0; --i) {
for (int j = 0; j <= s; ++j) {
pic[i][j] = sc.nextInt();
}
}
int count = 0; // 符合条件的树木数量
for (int i = 0; i < n; ++i) {
if (l - tree[i].x < s || l - tree[i].y < s) {
continue; // 越界跳过
}
int[][] temp = new int[s + 1][s + 1];
int sx = tree[i].x;
int sy = tree[i].y;
// 初始化临时数组
for (int j = 0; j <= s; ++j) {
for (int k = 0; k <= s; ++k) {
temp[j][k] = 0;
}
}
// 在临时数组中标记树木位置
for (int j = 0; j < n; ++j) {
if (tree[j].x - sx < 0 || tree[j].x - sx > s || tree[j].y - sy < 0 || tree[j].y - sy > s) {
continue;
}
temp[tree[j].x - sx][tree[j].y - sy] = 1;
}
int flag = 0;
// 检查临时数组与藏宝图是否匹配
for (int j = 0; j <= s; ++j) {
for (int k = 0; k <= s; ++k) {
if (temp[j][k] != pic[j][k]) {
flag = 1;
break;
}
}
if (flag == 1) {
break;
}
}
if (flag == 0) {
count++;
}
}
System.out.println(count); // 输出符合条件的树木数量
sc.close();
}
}