#abc357c. C - Sierpinski carpet

C - Sierpinski carpet

Score : 250250 points

问题陈述

对于一个非负整数 KK,我们定义一个 KK 级地毯如下:

  • 一个 00 级地毯是一个 1×11 \times 1 的网格,由一个单独的黑色单元格组成。
  • 对于 K>0K > 0,一个 KK 级地毯是一个 3K×3K3^K \times 3^K 的网格。当这个网格被划分为九个 3K1×3K13^{K-1} \times 3^{K-1} 的区块时:
    • 中心区块完全由白色单元格组成。
    • 其他八个区块是 (K1)(K-1) 级地毯。

你给定一个非负整数 NN。 请按照指定的格式打印一个 NN 级地毯。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

For a non-negative integer KK, we define a level-KK carpet as follows:

  • A level-00 carpet is a 1×11 \times 1 grid consisting of a single black cell.
  • For K>0K > 0, a level-KK carpet is a 3K×3K3^K \times 3^K grid. When this grid is divided into nine 3K1×3K13^{K-1} \times 3^{K-1} blocks:
    • The central block consists entirely of white cells.
    • The other eight blocks are level-(K1)(K-1) carpets.

You are given a non-negative integer NN.
Print a level-NN carpet according to the specified format.

Constraints

  • 0N60 \leq N \leq 6
  • NN is an integer.

Input

The input is given from Standard Input in the following format:

NN

Output

Print 3N3^N lines.
The ii-th line (1i3N1 \leq i \leq 3^N) should contain a string SiS_i of length 3N3^N consisting of . and #.
The jj-th character of SiS_i (1j3N1 \leq j \leq 3^N) should be # if the cell at the ii-th row from the top and jj-th column from the left of a level-NN carpet is black, and . if it is white.

Sample Input 1

1

Sample Output 1

###
#.#
###

A level-11 carpet is a 3×33 \times 3 grid as follows:

When output according to the specified format, it looks like the sample output.

Sample Input 2

2

Sample Output 2

#########
#.##.##.#
#########
###...###
#.#...#.#
###...###
#########
#.##.##.#
#########

A level-22 carpet is a 9×99 \times 9 grid.