In-place Sorting
题号:NC220436
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Woe is you – for your algorithms class you have to write a sorting algorithm, but you missed the relevant lecture! The subject was in-place sorting algorithms, which you deduce must be algorithms that leave each input number in its place and yet somehow also sort the sequence.

Of course you cannot change any of the numbers either, then the result would just be a difffferent sequence. But then it hits you: if you flflip a 6 upside-down, it becomes a 9, and vice versa! Certainly no one can complain about this since you changed none of the digits! The deadline to hand in the exercise is in fifive hours. Try to implement this sorting algorithm before then!

输入描述:

The input consists of:
    • A line with an integer n (2 ≤ n ≤ 10 000), the number of integers in the input sequence.
    • n lines, the ith of which contains a positive integer xi (1 ≤ xi ≤ 1018), the ith number of the sequence.

输出描述:

If the sequence cannot be sorted non-decreasingly by flipping some number 6 or 9 in input 1, output "not possible". Otherwise, output "possible" followed by the sorted sequence - each number on its own line.
If there is more than one valid solution, please output the smallest sequence.

示例1

输入

复制
4
9
7
7
9

输出

复制
possible
6
7
7
9
示例2

输入

复制
4
97
96
66
160

输出

复制
possible
67
69
69
160
示例3

输入

复制
3
80
97
79

输出

复制
impossible
示例4

输入

复制
2
197
166

输出

复制
possible
167
169