A classic Starcraft tactic is to mass a huge swarm of cheap units such as Zerglings and throw them all at the opponent at once. When both players do this simultaneously, the clash is quick, brutal, and messy. In this problem you simulate such a battle, which may involve far more Zerglings than a real game would ever allow.
The battlefield is an $N \times N$ grid. Every Zergling occupies exactly one square, and no two Zerglings ever share a square. Each Zergling starts with $35$ hit points. Its attack value is $5$ plus the attack upgrade of the player who controls it. When one Zergling attacks another, the damage dealt equals the attacker's attack value minus the armour upgrade of the player who owns the defender, and the defender loses that many hit points. (Attack values are $5$ to $8$ and armour upgrades are $0$ to $3$, so every hit deals at least $2$ damage.)
Every turn, each Zergling independently decides what to do, using this (not very bright) algorithm:
Whenever a rule allows more than one direction, directions are preferred in clockwise order starting from north: north, northeast, east, southeast, south, southwest, west, northwest. North points toward the first row and west toward the first column. Concretely, a Zergling attacks the enemy found in the first such direction, and it moves in the first such direction that reaches the minimizing square. If several enemies are tied for closest when choosing a move target, the northernmost of them is chosen, and among those the westernmost.
Once every Zergling has decided, the turn resolves in exactly this order:
The input contains several test cases and ends with a case in which $N = 0$; that terminating case is not processed.
Each test case is given as follows:
. is an empty square, a 1 is a Zergling owned by player 1, and a 2 is a Zergling owned by player 2. The first row is the north edge and the first column is the west edge.For each test case, output the grid after $t$ turns in the same format as the input grid: $N$ lines of $N$ characters each. Print one empty line between the outputs of consecutive test cases.