#P6972. [NEERC 2016] Kids Designing Kids

[NEERC 2016] Kids Designing Kids

题目描述

Kevin and Kimberly have freckles on their foreheads.

They both drew their freckle pictures on sheets of paper. Each picture is a rectangle of pixels: every cell either has a freckle or it has no freckle.

They are jokingly proposing that when they grow up, marry, and have a child, her freckle picture is produced as a result of the following procedure:

Kevin's and Kimberly's pictures are moved by a parallel translation, and then in each cell a child has a freckle if and only if exactly one of the parents has a freckle in this position.

Now they wonder, whether there is a parallel translation that gives their child a specific freckle picture (for example, a lightning), and what is this parallel translation.

输入格式

The first line contains two integers, h1andw1(1h1,w11000)h_{1 }and w_{1} (1 \le h_{1}, w_{1} \le 1000) -- the height and the width of Kevin's freckle picture. Each of the next h1h_{1} lines consists of w1w_{1} characters ב \times ' and ..‘. '. Character ב \times ' means that there is a freckle, and .‘. ' that there is not.

The next lines contain Kimberly's picture in the same format. Its height and width h2h_2 and w2w_2 follow the same constraints.

It is guaranteed that Kevin and Kimberly have at least one freckle each.

The next lines contain the picture they want for their child in the same format. Its dimensions h3h_{3} and w3w_{3} also have the same constraints.

输出格式

In the first line output YES if the desired picture can be produced, and NO otherwise.

If the answer is positive, then in the second line output two integers, xx and yy , with the following meaning: if you overlay the pictures so that their upper left corners coincide, then move Kimberly's picture xx cells right (negative number means moving picture left) and yy cells down (negative number means moving picture up), and then apply the procedure described above, the resulting picture can be moved by a parallel translation to coincide with the third picture from the input file.

3 3
..*
.*.
*.*
3 3
**.
..*
.*.
5 2
.*
*.
**
.*
*.

YES
0 2

提示

Time limit: 2 s, Memory limit: 512 MB.