Despite their best efforts, the persistent downpour in the city of Hail has left its citizens in shambles. As an experienced engineer, Cecilia has taken on a volunteer job in managing flood control. In her job, she creates "sandbag plans" to tell workers where to place sandbags in their respective work areas.
First, she is given a constraint plan, a grid with rows and columns consisting of only .
, X
, and ?
characters. To generate a sandbag plan from this constraint plan, she replaces all ?
characters with either .
or X
, indicating that a sandbag should or should not be placed in this cell, respectively. In her research, Cecilia has found that a constraint plan is effective if all rows in the constraint plan are pairwise distinct. Cecilia is interested in determining whether an effective plan can be made. Of course, doing this by hand is very time-consuming, so Cecilia needs your help!
Input Specification
The first line contains two space-separated integers, , the number of rows in the constraint plan, and the number of columns in the constraint plan.
The next lines contain a string of length , consisting of .
, X
, or ?
.
Output Specification
If it is possible to create an effective plan from the constraint plan, output YES
on the first line, followed by any effective constraint plan.
Otherwise, output NO
.
Constraints
In all subtasks,
Subtask 1 [5%]
Subtask 2 [5%]
Subtask 3 [10%]
Subtask 4 [80%]
No additional constraints.
Sample Input 1
4 4
.?XX
?X..
.??X
XX..
Sample Output 1
YES
.XXX
.X..
.X.X
XX..
Sample Input 2
5 5
.X?X?
.X..X
.XX.X
?.???
.X?.X
Sample Output 2
NO
Explanation of Sample 2
No effective plan exists for the given constraint plan.
Comments