import java.io.*;
import java.util.*;

public class cage_md_norotation implements Runnable {
	final int[] dx = new int[]{1, 0, -1, 0};
	final int[] dy = new int[]{0, 1, 0, -1};
	
	class Figure {
		int hei, wid;
		boolean[][] a;
		
		public Figure(boolean[][] a) {
			this.a = a;
			hei = a.length;
			wid = a[0].length;
		}
		
		public Figure(Scanner in) {
			hei = in.nextInt();
			wid = in.nextInt();
			a = new boolean[hei][wid];
			for (int i = 0; i < hei; i++) {
				String s = in.next();
				for (int j = 0; j < wid; j++) {
					a[i][j] = s.charAt(j) == '*';
				}
			}
		}
		
		boolean[][] mark;
		boolean freedom;
		int area;
		
		public int maxHollow() {
			mark = new boolean[hei][wid];
			int res = -1;
			for (int i = 0; i < hei; i++) {
				for (int j = 0; j < wid; j++) {
					if (!a[i][j] && !mark[i][j]) {
						freedom = false;
						area = 0;
						dfs(i, j);
						if (!freedom)
							res = Math.max(res, area);
					}
				}
			}
			return res;
		}

		private void dfs(int i, int j) {
			if (i < 0 || j < 0 || i >= hei || j >= wid) {
				freedom = true;
				return;
			}
			if (a[i][j] || mark[i][j])
				return;
			mark[i][j] = true;
			area++;
			for (int d = 0; d < 4; d++) {
				dfs(i + dx[d], j + dy[d]);
			}
		}

		public Figure superpose(Figure b, int dx, int dy) {
			int ax = 0, bx = 0;
			if (dx < 0) {
				ax = -dx;
			} else {
				bx = dx;
			}
			int x = Math.max(ax + hei, bx + b.hei);
			int ay = 0, by = 0;
			if (dy < 0) {
				ay = -dy;
			} else {
				by = dy;
			}
			int y = Math.max(ay + wid, by + b.wid);
			boolean[][] c = new boolean[x][y];
			for (int i = 0; i < hei; i++) {
				for (int j = 0; j < wid; j++) {
					c[ax + i][ay + j] = a[i][j];
				}
			}
			for (int i = 0; i < b.hei; i++) {
				for (int j = 0; j < b.wid; j++) {
					if (b.a[i][j]) {
						if (c[bx + i][by + j]) {
							return null;
						}
						c[bx + i][by + j] = true;
					}
				}
			}
			return new Figure(c);
		}
	}
	
	private Scanner in;
	private PrintWriter out;

	public void run() {
		try {
			solve();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	private void solve() throws IOException {
		Locale.setDefault(Locale.US);
		in = new Scanner(new FileReader("cage.in"));
		out = new PrintWriter("cage.out");
		Figure a = new Figure(in);
		Figure b = new Figure(in);
		int ans = -1;
		for (int dx = -b.hei; dx <= a.hei; dx++) {
			for (int dy = -b.wid; dy <= a.wid; dy++) {
				Figure c = a.superpose(b, dx, dy);
				if (c == null)
					continue;
				int cage = c.maxHollow();
				ans = Math.max(ans, cage);
			}
		}
		out.println(ans);
		in.close();
		out.close();
	}

	public static void main(String[] args) {
		new Thread(new cage_md_norotation()).start();
	}
}
