The voodoo lady once knitted a magical tapestry. Initially, she took a blank canvas that can be represented as an (r \times c) grid with (r) rows and (c) columns, thus having ((r + 1) \times (c + 1)) grid points. Then she did the following operation some number of times: she knitted a cycle on the canvas along the grid lines, passing through each grid point at most once within that cycle. Additionally, no two cycles share any grid point. In the end, it turned out that exactly one cycle passes through each of the ((r-1) \cdot (c-1)) inner grid points that don't lie on the canvas' border. Here are some examples of cycle arrangements for (r=2), (c=3) with the inner grid points highlighted: Then she left the canvas on the floor overnight. During the night, (r\cdot c) green frogs hopped on the canvas, with one sitting in each cell. But that was only the beginning of the voodoo lady's troubles! Because then, the old witch came to the canvas, and one-by-one, ripped away every knitted line on the canvas. Every time she ripped away a knitted line segment between two adjacent grid points, the frogs in the cells adjacent to that line segment got startled (there were one or two startled frogs, depending on whether the line segment was on a border or not). When a frog got startled, it instantly changed its color: if the frog was green, it became brown; and if it was brown, it became green again. If the cycles were arranged as in the pictures above, then the colors would be as follows (greyed out cells represent green frogs and white cells represent brown ones): When the voodoo lady came back to her canvas, she only saw that there were frogs of two colors on her canvas, but no knitted cycles. From the given arrangement of the frog colors, determine whether it could have been produced by the described process, and if so, help the voodoo lady to restore a possible arrangement of cycles. Each test contains multiple test cases. The first line |