题目描述
RSYJ is a computer scientist. He has developed many useful image search tools. But now he has encountered some problems.
We use a matrix
H × Hof to represent a bitmap with
H × Hsize, and each pixel of the
8‑bit bitmap is represented by the integer between
[0, 255].
Now, RSYJ have a
8‑bit bitmap
Awith
m × msize, and a
8‑bit bitmap
Bwith
m × msize.RSYJ uses an image processing software to copy bitmap
Bto some positions in bitmap
A. Due to RSYJ’s computer’s error, the value of each pixel in the bitmap
Bis added with an offset
k, which is an integer, but RSYJ doesn’t know what
kis.
Now your task is writing a program to help RSYJ find all positions of bitmap
Bin the bitmap
A. To simplify the problem, you only need output how many positions of bitmap
Bin bitmap
A.
For example, here are two bitmaps
Aand
B:
A:
10 9 3
11 6 5
15 7 2
B:
4 3
5 0
Bitmap
Bwas added with an offset
6. It becomes:
10 9
11 6
Bitmap
Bwas added with an offset
2. It becomes:
6 5
7 2
So there are two positions of bitmap
Bin bitmap
A.
输入
The first line of the input gives two positive integers
n,
m, representing the size of bitmap
Aand the size of bitmap
B, respectively.
The next
nlines give the bitmap
A. Each line contains
nintegers.
The next m lines give the bitmap
B. Each line contains
mintegers.
(1 ≤ n ≤ 2000 , 1 ≤ m ≤ 1000, 0 ≤ a
ij
≤ 255, 0 ≤ b
ij
≤ 255 )
输出
Please output an integer, representing the number of positions of bitmap
Bin bitmap
A.
3 2 1 2 9 3 4 7 5 6 0 3 4 5 6