Print all possible matrix of order n

I want to print all the possible matrix of order n using numbers from1-n. The only given constraint is that no elements should be repeated in a row and a column.
Ex. n=3
1 2 3
2 3 1
3 2 1

2 1 3
3 2 1
1 3 2
. . .
. . .
. . .

codejam

Indicium