Assume a permutation P[1], P[2], ..., P[n].
Now we have made N permutations Q[1], Q[2], ..., Q[N],
Q[i] is permutation P without element i (we subtract 1 from all elements bigger than i).
For example If permutation was [8 1 2 3 4 5 6 7] then without 5 it becomes [7 1 2 3 4 5 6].
Now suppose we had made a random shuffle of Q and we need to find initial permutation P.
Example : Let we have 3 elements and here is the shuffled Q :
1 2
1 2
1 2
Then obviously the initial permutation is simply [1 2 3] as it satisfy all the three conditions.
Now I want to have an algorithm or way to find out initial permutation if am given this Q.
NOTE : Algorithm can be exponential as I want to evaluate for N at max 50