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

public class cage_md 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);
        }
        
        public Figure flip() {
            boolean[][] b = new boolean[hei][wid];
            for (int i = 0; i < hei; i++) {
                for (int j = 0; j < wid; j++) {
                    b[i][wid - 1 - j] = a[i][j];
                }
            }
            return new Figure(b);
        }
        
        public Figure rotate() {
            boolean[][] b = new boolean[wid][hei];
            for (int i = 0; i < hei; i++) {
                for (int j = 0; j < wid; j++) {
                    b[wid - 1 - j][i] = a[i][j];
                }
            }
            return new Figure(b);
        }
        
        public Figure transform(int t) {
            Figure f = this;
            if (t >= 4) {
                f = f.flip();
                t -= 4;
            }
            for (int i = 0; i < t; i++)
                f = f.rotate();
            return f;
        }
    }
    
    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 b0 = new Figure(in);
        int ans = 0;
        int ansCount = 0;
        for (int t = 0; t < 8; t++) {
            Figure b = b0.transform(t);
            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();
                    if (ans < cage) {
                        ans = cage;
                        ansCount = 1;
                    } else if (ans == cage) {
                        ansCount++;
                    }
                }
            }
        }
        out.println(ans);
        System.out.println(ansCount);
        in.close();
        out.close();
    }

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