#1380
Unrated
Minegraphed
스페셜 저지
시간 제한
2s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Marika is developing a game called "Minegraphed" that involves moving around a 3D rectangular world.

Each cell of a parallelepiped game field is either an empty cell or an obstacle cell. You are always standing inside an empty cell, located either in the bottommost layer or on top of an obstacle cell. Each move can be made in one of four directions: north, east, south, or west. You make a move according to these rules:

  • If you try to move outside of the parallelepiped, then you can't make this move.
  • Otherwise, if the cell in front of you is empty, then you move one cell forward and then fall towards the bottom until you reach the bottommost layer or an obstacle cell.
  • Otherwise, if you are in non-topmost layer, the cell in front of you is an obstacle, the cell above you and the cell above that obstacle are both empty, then you move (climb up) on top of that obstacle.
  • Otherwise, you can't make this move.

Marika prepared a directed graph with nn vertices. Now she wants to lay out the field and label nn different possible standing positions with numbers from 1 to nn, so that it is possible to get from the cell labeled ii to the cell labeled jj by making valid moves if and only if in Marika's graph it is possible to get from vertex ii to vertex jj along the edges of the graph. Help Marika design a field satisfying this property.

입력

The first line contains a single integer nn (1n91 \le n \le 9) — the number of vertices. Each of the next nn lines contains nn integers equal to 0 or 1. The jj-th number in the ii-th line is 1 if there is an edge from vertex ii to vertex jj and 0 otherwise. The ii-th number in the ii-th line is always zero.

출력

Output a layer-by-layer description of a field that has the same reachability as the given graph.

The first line should contain three positive integers xx, yy, and zz, the west-east, north-south, and top-bottom sizes of the designed parallelepiped. Blocks describing zz layers should follow, from the topmost layer to the bottommost layer, separated by single empty lines. Each block should contain yy lines of length xx, consisting of dots ('.'), hashes ('#'), and digits from 1 to nn. A hash denotes an obstacle cell. A dot denotes an unlabeled empty cell. A digit denotes a labeled empty cell. Each digit from 1 to nn should appear exactly once. Each digit should be located either in the bottommost layer or on top of an obstacle cell. It is okay for obstacles to be "hanging in the air" (there is no gravity for them).

The volume of the field x×y×zx \times y \times z should not exceed 10610^6. It is guaranteed that there is a correct field fitting into this limit for any possible graph in the input.

예제 입력 1

4
0 1 0 1
0 0 1 0
0 1 0 0
1 0 0 0

예제 출력 1

4 2 3
..#.
.4..

####
1#.#

..3.
#2..

노트

Note that you can climb up from cell 1 to cell 4, but you cannot climb up from cell 2 to cell 1 because of a "ceiling" obstacle.

코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.