import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
void answer(int count)
{
}
/**
* @param H ホーム画面縦の区画数
* @param W ホーム画面横の区画数
* @param array[Y][X] ホーム画面の配置
* @param S ウィジェットの縦サイズ
* @param T ウィジェットの横サイズ
*/
void resolve(int H, int W, int[][] array, int S, int T)
{
// your code goes here
int count = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
boolean flag = true;
for (int p = 0; flag && p < S; p++) {
for (int q = 0; flag && q < T; q++) {
int x = j + q;
int y = i + p;
if (x >= W || y >= H) {
flag = false;
} else if (array[y][x] == 1) {
flag = false;
}
}
}
if (flag) {
count++;
}
}
}
answer(count);
}
{
Main instance = new Main();
String[] hw
= in.
readLine().
split(" "); final int H
= Integer.
parseInt(hw
[0]); // ホーム画面縦の区画数 final int W
= Integer.
parseInt(hw
[1]); // ホーム画面横の区画数
int[][] home = new int[H][W];
for (int y = 0; y < H; y++)
{
for (int x = 0; x < W; x++)
{
home[y][x] = (int)(line.charAt(x) - '0');
}
}
final int N
= Integer.
parseInt(in.
readLine());
for (int i = 0; i < N; i++)
{
String[] st
= in.
readLine().
split(" "); int s
= Integer.
parseInt(st
[0]); // ウィジェットの縦サイズ int t
= Integer.
parseInt(st
[1]); // ウィジェットの横サイズ
instance.resolve(H, W, home, s, t);
}
}
}
CmltcG9ydCBqYXZhLnV0aWwuKjsKaW1wb3J0IGphdmEubGFuZy4qOwppbXBvcnQgamF2YS5pby4qOwoKY2xhc3MgTWFpbgp7Cgl2b2lkIGFuc3dlcihpbnQgY291bnQpCgl7CgkJU3lzdGVtLm91dC5wcmludGxuKGNvdW50KTsKCX0KCQoJLyoqCgkgKiBAcGFyYW0gSCAgICAgICAgICAgIOODm+ODvOODoOeUu+mdoue4puOBruWMuueUu+aVsAoJICogQHBhcmFtIFcgICAgICAgICAgICDjg5vjg7zjg6DnlLvpnaLmqKrjga7ljLrnlLvmlbAKCSAqIEBwYXJhbSBhcnJheVtZXVtYXSAg44Ob44O844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