Plato's Blocks

No attempts yetTime limit1sMemory limit128 MB

Problem

Plato believed that what we perceive is only a shadow of reality. Recent archaeological excavations suggest this belief may have grown out of Plato's youthful fascination with a set of cleverly designed blocks. Each block has the curious property that, when it is held with any one face toward a light source, it casts the shadow of some letter, number, shape, or pattern. The three faces meeting at a single corner can correspond to three different shadow patterns; opposite faces, naturally, cast shadows that are mirror images of one another.

Each block is built by gluing small unit cubes together into a single connected object. As an example, the figures below show, layer by layer, the internal structure of a block that can cast the shadows of the letters "E", "G", or "B".

Only part of the original set of blocks has been recovered, but curious scientists want to know which combinations of shadows are possible. Your program will help them: it reads groups of three shadow patterns and, for each group, reports whether a single solid block can be built that casts exactly those three shadows.

Input

The input contains a sequence of data sets. Each data set specifies a dimension followed by three shadow patterns. The first line of a data set contains a positive integer $n$ ($1 \le n \le 20$) giving the size of the patterns. The rest of the data set consists of $3n$ lines, each a string of $n$ characters drawn from "X" and "-". Every group of $n$ consecutive lines is one pattern. An "X" marks a position where the finished solid must cast a shadow, and a "-" marks a position where light must pass through. You may assume that each input pattern has at least one "X" on every edge. The input ends with a line containing a single 0 in place of a dimension.

Output

For each data set, print the data set number together with one of the following two messages:

Valid set of patterns
Impossible combination

For the $i$-th data set, print the answer on a single line in the form Data set i: Valid set of patterns or Data set i: Impossible combination (the number $i$ starts from 1). A set of patterns is valid if it is possible to build, by gluing unit cubes together face to face, a single connected solid that casts the shadow of each of the three input patterns.