#include <bits/stdc++.h>

std::vector<int> MPAlgorithm(const std::string& str)
{
	std::vector<int> ret(str.size() + 1);
	ret[0] = -1;
	for (int i{}; i < (int)str.size(); i++)
	{
		int prev{ret[i]};
		while (prev >= 0 && str[prev] != str[i]) prev = ret[prev];
		ret[i + 1] = prev + 1;
	}
	return std::move(ret);
}

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	std::vector<std::string> field(H);
	for (auto& e: field) std::cin >> e;
	int R, C;
	scanf("%d%d", &R, &C);
	std::vector<std::string> pattern(R);
	for (auto& e: pattern) std::cin >> e;
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vvi mp(R);
	for (int i{}; i < R; i++)
		mp[i] = MPAlgorithm(pattern[i]);
	for (int row{}; row + R <= H; row++)
	{
		std::bitset<1000> bs{};
		for (int i{}; i + C <= W; i++)
			bs[i] = true;
		for (int p_r{}; p_r < R; p_r++)
		{
			for (int i{}, length{}; i < W; i++)
			{
				while (length >= 0 && field[row + p_r][i] != pattern[p_r][length]) length = mp[p_r][length];
				length++;
				if (length < C)
				{
					if (i - C + 1 >= 0)
						bs[i - C + 1] = false;
					continue;
				}
				length = mp[p_r][length];
			}
		}
		for (int col{}; col < W; col++)
			if (bs[col])
				printf("%d %d\n", row, col);
	}

	return 0;
}

### Prompt

Please formulate a Cpp solution to the following problem:

Find places where a R × C pattern is found within a H × W region. Print top-left coordinates (i, j) of sub-regions where the pattern found. The top-left and bottom-right coordinates of the region is (0, 0) and (H-1, W-1) respectively.

Constraints

* 1 ≤ H, W ≤ 1000
* 1 ≤ R, C ≤ 1000
* The input consists of alphabetical characters and digits

Input

In the first line, two integers H and W are given. In the following H lines, i-th lines of the region are given.

In the next line, two integers R and C are given. In the following R lines, i-th lines of the pattern are given.

Example

Input

4 5
00010
00101
00010
00100
3 2
10
01
10


Output

0 3
1 2

### Response

```cpp
#include <bits/stdc++.h>

std::vector<int> MPAlgorithm(const std::string& str)
{
	std::vector<int> ret(str.size() + 1);
	ret[0] = -1;
	for (int i{}; i < (int)str.size(); i++)
	{
		int prev{ret[i]};
		while (prev >= 0 && str[prev] != str[i]) prev = ret[prev];
		ret[i + 1] = prev + 1;
	}
	return std::move(ret);
}

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);
	std::vector<std::string> field(H);
	for (auto& e: field) std::cin >> e;
	int R, C;
	scanf("%d%d", &R, &C);
	std::vector<std::string> pattern(R);
	for (auto& e: pattern) std::cin >> e;
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vvi mp(R);
	for (int i{}; i < R; i++)
		mp[i] = MPAlgorithm(pattern[i]);
	for (int row{}; row + R <= H; row++)
	{
		std::bitset<1000> bs{};
		for (int i{}; i + C <= W; i++)
			bs[i] = true;
		for (int p_r{}; p_r < R; p_r++)
		{
			for (int i{}, length{}; i < W; i++)
			{
				while (length >= 0 && field[row + p_r][i] != pattern[p_r][length]) length = mp[p_r][length];
				length++;
				if (length < C)
				{
					if (i - C + 1 >= 0)
						bs[i - C + 1] = false;
					continue;
				}
				length = mp[p_r][length];
			}
		}
		for (int col{}; col < W; col++)
			if (bs[col])
				printf("%d %d\n", row, col);
	}

	return 0;
}

```