Find the permutation This is part of an exercise I did on an assignment but I am having trouble remembering how to complete the exercise (even though I got full marks on my assignment).
Let $P_1=(3\,4\,1\,2\,5), P_2+(3\,5\,1\,2\,4),$ and $P_3=(5\,1\,4\,2\,3)$ be three permutations.
Find the permutation: $P_3^{-1}$
Here is my answer as I wrote it on the assignment.

Even though I received full marks on the assignment I am no longer sure that it is correct. When I try to work it out now I am getting $P_3^{-1}=(2\,1\,4\,5\,3)$.
I could really use some help with this. I'm not sure which answer is correct and I feel that I am just confusing myself further.
If my first answer (the image) is correct, could you please remind me of how I got it?
Thanks
 A: Here's an easy way for beginners to find the inverse of a permutation:
Remember when you first started permutations (probably not that long ago), you wrote them using two rows. So the permutation in question would have looked like this
$$P_3 = \begin{pmatrix} 1 & 2 & 3 & 4 & 5 \\ 5 & 1 & 4 & 2 & 3\end{pmatrix}.$$
You understood that to mean that whatever element was in the first position was moved to the fifth position and whatever element was in the second slot was moved to the first.
To find the inverse of $P_3$, flip the rows, and then sort the columns in ascending order. That is, first flip the rows
$$P_3^{-1} = \begin{pmatrix} 5 & 1 & 4 & 2 & 3 \\ 1 & 2 & 3 & 4 & 5\end{pmatrix}.$$
Now just reorder the columns so that the top row is ascending. That is, the second column, which says $\begin{matrix}1\\2\end{matrix}$ will be moved to the first column, etc. You should get
$$P_3^{-1} = \begin{pmatrix} 1 & 2 & 3 & 4 & 5\\ 2 & 4 & 5 & 3 & 1 \end{pmatrix}.$$
Finally, strip off the top row to get the answer
$$P_3^{-1} = \begin{pmatrix} 2 & 4 & 5 & 3 & 1 \end{pmatrix}.$$
Of course, you can check this by putting any 5 symbol sequence of objects through $P_3$, then through $P_3^{-1}$, and you should get the original list back. Then put it through $P_3^{-1}$ followed by $P_3$, and again you should get the original list back.
For example, let the input be the list $(a\ b\ c\ d\ e)$. Put that through $P_3$ and you get $(b\ d\ e\ c\ a)$. Now put that through $P_3^{-1}$ and you get $(a\ b\ c\ d\ e)$.
