Vacation Rentals

No attempts yetTime limit1sMemory limit128 MB

Problem

The Fifth Season Resort has a number of condominiums. They are usually occupied by their owners, but while empty they are offered as vacation rentals. The resort has at most $26$ condominiums, so each one is identified by a single uppercase letter.

A guest submits a reservation request with an arrival date and a departure date. Existing reservations are mostly the owners' own, so they cannot be moved to another unit. The guest, however, may be moved from one unit to another between nights. For example, the guest might stay in unit B for the first three nights and then move to unit F for the rest of the stay.

Reservations are counted in nights. A request with arrival date $a$ and departure date $d$ means the guest occupies a room on the nights of days $a, a+1, \dots, d-1$ and leaves on day $d$. Thus a one-night reservation departs the day after arrival.

Your task is to satisfy the request without changing any existing reservation, using the minimum number of transfers (moves from one unit to another) during the requested period.

Input

The input contains several test cases.

Each test case begins with a line containing two positive integers $M$ and $N$: $M$ is the number of consecutive days covered by the reservation table, and $N$ is the number of units. There are at most $100$ days and at least $3$ units. Days are numbered $1, 2, \dots, M$, and units are labeled with consecutive uppercase letters starting at $A$.

The next $M$ lines describe the reservation table. The $i$-th line corresponds to day $i$, and its $j$-th character corresponds to the $j$-th unit ($A, B, C, \dots$). The character X means the unit is already reserved that day, and O means it is available.

The table is followed by one line with two integers: the arrival date and the departure date of the new request. The arrival date is in the range $1 \dots M$, and the departure date is greater than the arrival date and at most $M+1$.

The input ends with a line containing $M = N = 0$, which is not processed.

Output

For each test case, print the case number followed by a colon, then a blank line.

If the request can be satisfied, print a schedule that uses the minimum number of transfers. Each line describes one continuous stay in a single unit and has the form:

<unit>: <start>-<end>

where <unit> is the unit letter, <start> is the day the guest moves into that unit, and <end> is the day the guest moves out. Lines are ordered by increasing start date.

Tie-breaking. Several schedules may reach the minimum number of transfers. Among them, choose the one whose unit labels are lexicographically smallest day by day: prefer the lowest unit label on the first night (so $A$ is preferred over $B$); if there is still a tie, prefer the lowest label on the second night, and so on. This makes the answer unique.

If the request cannot be satisfied, print the single line:

Not available

Separate the output of consecutive test cases with a blank line.