Time limit
2s
Memory limit
128 MB
Sejun has two grid papers. The first paper has size N1 x M1, and the second paper has size N2 x M2. Each cell is marked either as an empty cell . or a filled cell X.
The two papers may be placed so that they overlap, but they do not have to overlap. Before placing each paper, it may be rotated by a multiple of 90 degrees or flipped. After the two papers are placed, any cell that is X on at least one paper is considered filled.
Find the maximum possible area of a rectangle made only of X cells.
The first line contains N1 and M1, the size of the first paper. The next N1 lines contain the first paper.
The next line contains N2 and M2, the size of the second paper. The next N2 lines contain the second paper.
Print the area of the largest rectangle made only of X cells.
. or X.