Mateo, the owner of Austin's most popular video game store, was in a generous mood one day. He decides to give a gift to each of the $$$n$$$ people currently in his store and he has $$$n$$$ distinct prizes labeled $$$0, 1, \dots, n - 1$$$ to give out. Since Mateo never does anything the simple way, he comes up with the following scheme to give the prizes out.
He gives each of the $$$n$$$ people in the store unique numbers from $$$1$$$ to $$$n$$$ (inclusive). He then asks everyone to form a line and so the resulting ordering of the people can be written as the sequence $$$[x_1, x_2, \dots, x_n]$$$ (where each $$$x_i$$$ is unique and $$$1 \leq x_i \leq n$$$). The prize which Mateo gives person $$$x_j$$$ is equal to $$$x_1 \cdot x_2 \cdot \ldots \cdot x_{j-1} \cdot x_{j} \pmod{n}$$$. Unfortunately, Mateo only has one of each prize so he asks you to come up with an ordering of the $$$n$$$ people so that each person will get a unique prize number.
The first and only line of input will contain a single integer $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$), representing the number of people in the store.
A space-separated permutation of the numbers from $$$1$$$ to $$$n$$$ (inclusive), representing the ordering of people such that each person can get a distinct prize. Output -1 if there is no such permutation.
7
1 4 3 6 5 2 7
8
-1
In the first example: