#D3. Are the cards the same
Are the cards the same
Description
On Monday during the school-wide cleaning, Xiaohua and Xiaoming were assigned by the labor committee to help the art teacher organize items in the art room. While assisting, Xiaoming noticed a pile of cards. These cards were all square-shaped, with equal-sized grids drawn on both sides. Due to their varying sizes, each card had a different number of grids—some had grids, others had grids, grids, and so on, with the largest card featuring a grid. Xiaoming observed that some grids were colored, and the colors on opposite sides of the cards were identical. Xiaoming asked Xiaohua if they knew what the cards were for. Xiaohua speculated that they might be used for word puzzles or drawings. His guess was confirmed by the teacher, who instructed them to sort the cards, grouping identical ones together. Xiaohua and Xiaoming immediately began working. Xiaohua picked up a card and asked Xiaoming to help find a matching one. Xiaoming handed over a card, and Xiaohua glanced at it: "Don’t joke around—quick, find the one that matches mine." "This one is the same as yours," Xiaoming replied, "Look, flip it over and rotate it degrees—it looks identical to yours." Clearly, it was hard to tell if the cards were the same at a glance. Now, please help write a program specifically designed to determine whether two cards are identical.
Format
Input
The first line of the input file contains the number of cells per side, , for the first card. The following line consists of an matrix representing the pattern of the first card, where indicates an uncolored cell and indicates a colored cell, with spaces separating the horizontal data. The next line contains the number of cells per side, , for the second card, followed by an matrix representing the pattern of the second card, using the same notation as above.
Output
The output file contains only a or to indicate whether they are the same or different.
Samples
input1
4
0 0 1 0
0 0 0 0
0 1 0 0
0 0 1 1
4
0 0 0 0
0 0 1 0
1 0 0 1
0 0 0 1
output1
yes