atcoder#ABC279C. [ABC279C] RANDOM
[ABC279C] RANDOM
Score : points
Problem Statement
You are given patterns and consisting of #
and .
, each with rows and columns.
The pattern is given as strings, and the -th character of represents the element at the -th row and -th column. The same goes for .
Determine whether can be made equal to by rearranging the columns of .
Here, rearranging the columns of a pattern is done as follows.
- Choose a permutation of .
- Then, for every integer such that , simultaneously do the following. - For every integer such that , simultaneously replace the element at the -th row and -th column of with the element at the -th row and -th column.
- For every integer such that , simultaneously replace the element at the -th row and -th column of with the element at the -th row and -th column.
Constraints
- and are integers.
- and are strings of length consisting of
#
and.
.
Input
The input is given from Standard Input in the following format:
Output
If can be made equal to , print Yes
; otherwise, print No
.
3 4
##.#
##..
#...
.###
..##
...#
Yes
If you, for instance, arrange the -rd, -th, -nd, and -st columns of in this order from left to right, will be equal to .
3 3
#.#
.#.
#.#
##.
##.
.#.
No
In this input, cannot be made equal to .
2 1
#
.
#
.
Yes
It is possible that .
8 7
#..#..#
.##.##.
#..#..#
.##.##.
#..#..#
.##.##.
#..#..#
.##.##.
....###
####...
....###
####...
....###
####...
....###
####...
Yes