itertools permutations
  1. from itertools import permutations
  2. N=int(input())
  3. P=list(map(int,input().split()))
  4. Q=list(map(int,input().split()))
  5. Dic=sorted(P)
  6. per_P=permutations(Dic,N)
  7. per_Q=permutations(Dic,N)
  8. count_P=0
  9. count_Q=0
  10. print(P)
  11.  
  12. for i in per_P:
  13.         count_P+=1
  14.         if P==i:
  15.                 break
  16. for j in per_Q:
  17.         count_Q+=1
  18.         if Q==j:
  19.                 break
  20. print(Dic)     
  21.  
Parsed in 0.003 seconds