Welcome to ZOJ
 Contests Information Problems Runs Statistics Ranklist Clarification
106 - ZOJ Monthly, May 2011 - H
Fractal

Time Limit: 2 Seconds      Memory Limit: 65536 KB

A fractal is an object or quantity that displays self-similarity, in a somewhat technical sense, on all scales. The object need not exhibit exactly the same structure at all scales, but the same "type" of structures must appear on all scales. Given an m * n bitmap bmp, your job is to draw a "k-F bitmap of bmp". A "k-F bitmap of bmp" is made up of m * n sub-bitmap with blank bit in bmp replaced by blank region and no blank bit int bmp replaced by "(k-1)-F bitmap of bmp", and "1-F bitmap of bmp" is bmp itself. More details in sample.

Input

There will be multiple cases. Process to the End Of File.

Each case bigin with two positive integer m and n both less than 12, then a m * n bitmap bmp with trailing blanks if necessary. At last, a positive integer k no more than 12 indicate the desired bitmap.

Ouput

First ouput "Fractal #%d:" in a line where "%d" is the case id, ans output the answer to this case. Seperate cases with a blank line. No trailing blanks are allowed in the output.

Sample Input

```1 3
##
4
3 3
X X
X
X X
3
6 6
+----+
| /\ |
|/  \|
| /\ |
| \/ |
+----+
2
```

Sample Output

```Fractal #1:
## ##    ## ##             ## ##    ## ##

Fractal #2:
X X   X X         X X   X X
X     X           X     X
X X   X X         X X   X X
X X               X X
X                 X
X X               X X
X X   X X         X X   X X
X     X           X     X
X X   X X         X X   X X
X X   X X
X     X
X X   X X
X X
X
X X
X X   X X
X     X
X X   X X
X X   X X         X X   X X
X     X           X     X
X X   X X         X X   X X
X X               X X
X                 X
X X               X X
X X   X X         X X   X X
X     X           X     X
X X   X X         X X   X X

Fractal #3:
+----++----++----++----++----++----+
| /\ || /\ || /\ || /\ || /\ || /\ |
|/  \||/  \||/  \||/  \||/  \||/  \|
| /\ || /\ || /\ || /\ || /\ || /\ |
| \/ || \/ || \/ || \/ || \/ || \/ |
+----++----++----++----++----++----+
+----+      +----++----+      +----+
| /\ |      | /\ || /\ |      | /\ |
|/  \|      |/  \||/  \|      |/  \|
| /\ |      | /\ || /\ |      | /\ |
| \/ |      | \/ || \/ |      | \/ |
+----+      +----++----+      +----+
+----++----+            +----++----+
| /\ || /\ |            | /\ || /\ |
|/  \||/  \|            |/  \||/  \|
| /\ || /\ |            | /\ || /\ |
| \/ || \/ |            | \/ || \/ |
+----++----+            +----++----+
+----+      +----++----+      +----+
| /\ |      | /\ || /\ |      | /\ |
|/  \|      |/  \||/  \|      |/  \|
| /\ |      | /\ || /\ |      | /\ |
| \/ |      | \/ || \/ |      | \/ |
+----+      +----++----+      +----+
+----+      +----++----+      +----+
| /\ |      | /\ || /\ |      | /\ |
|/  \|      |/  \||/  \|      |/  \|
| /\ |      | /\ || /\ |      | /\ |
| \/ |      | \/ || \/ |      | \/ |
+----+      +----++----+      +----+
+----++----++----++----++----++----+
| /\ || /\ || /\ || /\ || /\ || /\ |
|/  \||/  \||/  \||/  \||/  \||/  \|
| /\ || /\ || /\ || /\ || /\ || /\ |
| \/ || \/ || \/ || \/ || \/ || \/ |
+----++----++----++----++----++----+
```

Author: WU, Zejun
Submit    Status