Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T = int(input())
- for i in range(T):
- n = int(input())
- A = list(map(int,input().strip().split()))
- C = []
- for j in range(len(A)):
- c = 0
- a = A[j]
- while ((a-1)!=j):
- a = A[a-1]
- c = c+1
- C.append(str(c+1))
- print(' '.join(C))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement