Codeforces Round 199 (Div. 2)
A
Xenia and Divisors
Codeforces
1200
原题
←B →
翻译中…

Xenia the mathematician has a sequence consisting of $*n*$ ($*n*$ is divisible by 3) positive integers, each of them is at most 7. She wants to split the sequence into groups of three so that for each group of three $*a*, *b*, *c*$ the following conditions held:

翻译中…
  • $*a* < *b* < *c*$;
  • $*a*$ divides $*b*$, $*b*$ divides $*c*$.
翻译中…

Naturally, Xenia wants each element of the sequence to belong to exactly one group of three. Thus, if the required partition exists, then it has image groups of three.

翻译中…

Help Xenia, find the required partition or else say that it doesn't exist.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ $(3 ≤ *n* ≤ 99999)$ — the number of elements in the sequence. The next line contains $*n*$ positive integers, each of them is at most 7.

翻译中…

It is guaranteed that $*n*$ is divisible by 3.

翻译中…

Output

翻译中…

If the required partition exists, print image groups of three. Print each group as values of the elements it contains. You should print values in increasing order. Separate the groups and integers in groups by whitespaces. If there are multiple solutions, you can print any of them.

翻译中…

If there is no solution, print -1.

翻译中…

样例

Input #1
6
1 1 1 2 2 2
Output #1
-1
InputCopy OutputCopy
Input #2
6
2 2 1 1 4 6
Output #2
1 2 4
1 2 6
InputCopy OutputCopy
题目信息
题号
342A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。