K. Kilt Quilt
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output

An image set to be painted onto a tartan canvas consists of $$$n$$$ rows of $$$m$$$ pixels with each colour represented as a lowercase letter of the alphabet.

You are going to paint the image using long brush strokes that cover either a whole row of $$$m$$$ pixels, or a whole column of $$$n$$$ pixels. Each brush stroke overwrites any pixels that were previously there. You must cover the whole canvas with brush strokes.

Is it possible to do so? If so, output a sequence of instructions of the form x=[1-m] [a-z] or y=[1-n] [a-z]. If there are multiple sequences, output any of the shortest possible lists of instructions.

Illustration of Sample Input 2.

Input
  • The first line of input contains $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 200$$$)

  • The next $$$n$$$ lines of input contain a string of $$$m$$$ lowercase characters in a-z, each representing a colour.
Output

On the first line, output the minimum number of instructions needed. If no sequence of instructions covers the canvas, output impossible and exit.

On each of the next lines, output one instruction to follow in order. For example, "x=5 z", and "y=100 b" are both valid instructions.

Examples
Input
4 6
aaaaba
aaaaba
aaaaba
aaaaba
Output
5
y=1 a
y=2 a
y=3 a
y=4 a
x=5 b
Input
4 4
laaq
daaq
laaq
bbbq
Output
6
x=1 l
y=2 d
x=2 a
x=3 a
y=4 b
x=4 q