405996: GYM102215 B Rearrange Columns

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Rearrange Columnstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

There is a cell field of size $$$2 \times n$$$. Some cells are marked. You have to rearrange its columns in such a way that all marked cells form a connected area.

Marked cells form a connected area if from every one of them it is possible to reach every other one, moving up, down, left or right (not always in one direction), and all the cells on the way are marked too.

Input

The input describes a field and consists of two strings of the same length $$$n$$$ ($$$1 \le n \le 1000$$$). They consist of characters «.» and «#» that denote not marked and marked cells, respectively. It is guaranteed that there exists at least one marked cell.

Output

In the first line output «YES» or «NO», depending on if the columns can be rearranged or not.

In case of the positive answer output two strings of characters «.» and «#» — the field after the columns are rearranged.

If there are many possible answers, output any of them.

ExamplesInput
#..#
.#.#
Output
YES
##..
.##.
Input
..##
##..
Output
NO

加入题单

上一题 下一题 算法标签: