Determine the Photo Position
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

You have taken the graduation picture of graduates. The picture could be regarded as a matrix A of , each element in A is 0 or 1, representing a blank background or a student, respectively.

However, teachers are too busy to take photos with students and only took a group photo themselves. The photo could be regarded as a matrix B of  where each element is 2 representing a teacher.

As a master of photoshop, your job is to put photo B into photo A with the following constraints:
  • you are not allowed to split, rotate or scale the picture, but only translation.
  • each element in matrix B should overlap with an element in A completely, and each teacher should overlap with a blank background, not shelter from a student. 

Please calculate the possible ways that you can put photo B into photo A.

输入描述:

The first line contains two integers  indicating the size of photos A and B. 

In the next $n$ lines,each line contains  characters of '0' or '1',representing the matrix A.

The last line contains  characters of '2', representing matrix B. 

输出描述:

Output one integer in a line, indicating the answer.
示例1

输入

复制
5 3
00000
01110
01110
01110
00000
222

输出

复制
6
示例2

输入

复制
3 2
101
010
101
22

输出

复制
0
示例3

输入

复制
3 1
101
010
101
2

输出

复制
4