Geek and his classmates are playing a prank on their Computer Science teacher. They change places every time the teacher turns to look at the blackboard. 
Each of the N students in the class can be identified by a unique roll number X and each desk has a number i associated with it. Only one student can sit on one desk. 
Each time the teacher turns her back, a student with roll number X sitting on desk number i gets up and takes the place of the student with roll number i.
If the current position of N students in the class is given to you in an array, such that i is the desk number and a[i] is the roll number of the student sitting on the desk, can you modify a[ ] to represent the next position of all the students?
Note: The array a[ ] will be a permutation of the array : {0, 1, 2, 3, ...., n-1}.
Example 1:
Input:
N = 6
a[] = {0, 5, 1, 2, 4, 3}
Output: 0 3 5 1 4 2
Explanation: After reshuffling, the modified 
position of all the students would be 
{0, 3, 5, 1, 4, 2}.
Example 2:
Input:
N = 5
a[] = {4, 3, 2, 1, 0}
Output: 0 1 2 3 4 
Explanation: After reshuffling, the modified 
position of all the students would be 
{0, 1, 2, 3, 4}.
Your Task:  
You dont need to read input or print anything. Complete the function prank() which takes the array a[ ] and its size N as input parameters and modifies the array in-place to reflect the new arrangement.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
 
Constraints:
1 ≤ N ≤ 10^{5}
0 ≤ a[i] ≤ N-1

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3



class Solution:

    def prank(self, a, n): 

        #code here

Solutions:
class Solution:

	def prank(self, a, n):
		output = [0] * n
		for (i, item) in enumerate(a):
			output[i] = a[item]
		for i in range(n):
			a[i] = output[i]
		return


class Solution:

	def prank(self, a, n):
		for i in range(n):
			a[i] = a[i] + a[a[i]] % n * n
		for i in range(n):
			a[i] = a[i] // n


class Solution:

	def prank(self, a, n):
		pos = [-1] * n
		for i in range(n):
			pos[a[i]] = i
		res = [0] * n
		for i in range(n):
			res[pos[i]] = a[i]
		for i in range(n):
			a[i] = res[i]


class Solution:

	def prank(self, a, n):
		hmap = {}
		for i in range(n):
			hmap[a[i]] = i
		for (key, val) in hmap.items():
			idx = hmap[val]
			toidx = hmap[idx]
			a[toidx] = val


class Solution:

	def prank(self, a, n):
		temp = []
		for i in range(0, n):
			temp.append(a[a[i]])
		for i in range(0, n):
			a[i] = temp[i]
		return a


class Solution:

	def prank(self, a, n):
		res = []
		for i in range(n):
			res.append(a[i])
		for i in range(n):
			a[i] = res[res[i]]
		return res


class Solution:

	def prank(self, a, n):
		result = [0] * n
		for i in range(n):
			result[i] = a[a[i]]
		a[:] = result[:]


class Solution:

	def prank(self, a, n):
		d = {}
		for i in range(n):
			d[a[i]] = i
		l = [-1] * n
		for i in range(n):
			l[d[i]] = a[i]
		for i in range(n):
			a[i] = l[i]


class Solution:

	def prank(self, a, n):
		getindex = [None] * n
		lst = [None] * n
		for i in range(n):
			getindex[a[i]] = i
		for i in range(n):
			val = a[i]
			pos = getindex[i]
			lst[pos] = val
		for i in range(n):
			a[i] = lst[i]
		return a


class Solution:

	def prank(self, a, n):
		temp = [0] * n
		for i in range(n):
			temp[i] = a[a[i]]
		for i in range(n):
			a[i] = temp[i]
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().strip().split()))
		ob = Solution()
		ob.prank(a, n)
		for i in a:
			print(i, end=' ')
		print()


class Solution:

	def prank(self, a, n):
		li = [0] * n
		for i in range(n):
			li[i] = a[a[i]]
		for i in range(n):
			a[i] = li[i]
		return a


class Solution:

	def prank(self, a, n):
		copy_a = a.copy()
		for i in range(n):
			a[i] = copy_a[a[i]]


class Solution:

	def prank(self, a, n):
		d1 = {}
		d2 = {}
		lst = []
		for i in range(n):
			d1[i] = a[i]
		for key in list(d1.keys()):
			d2[key] = d1[d1[key]]
		keys = list(d1.keys())
		keys.sort()
		for i in range(0, len(keys)):
			lst.append(d2[i])
		a[:] = lst
		return a


class Solution:

	def prank(self, a, n):
		k = a.copy()
		for i in range(len(a)):
			a[i] = k[k[i]]
		return a


class Solution:

	def prank(self, a, n):
		x = [0] * n
		y = {}
		for i in range(0, n):
			y[a[i]] = i
		for i in range(0, n):
			x[y[i]] = a[i]
		for i in range(0, n):
			a[i] = x[i]


class Solution:

	def prank(self, a, n):
		a1 = []
		for i in a:
			a1.append(a[i])
		a.clear()
		for i in a1:
			a.append(i)


class Solution:

	def prank(self, a, n):
		mp = dict()
		for i in range(n):
			mp[a[i]] = i
		ans = [0] * n
		for i in range(n):
			pos = mp[i]
			ans[pos] = a[i]
		for i in range(n):
			a[i] = ans[i]


class Solution:

	def prank(self, a, n):
		l = []
		dic = {a[i]: i for i in range(n)}
		dic2 = {i: a[i] for i in range(n)}
		for i in a:
			l.append(a[dic[dic2[i]]])
		a[:] = l


from collections import defaultdict

class Solution:

	def prank(self, a, n):
		d = defaultdict(lambda : 0)
		for i in range(n):
			d[i] = a[i]
		for i in range(n):
			if a[i] == i:
				continue
			else:
				a[i] = d[a[i]]


class Solution:

	def prank(self, a, n):
		b = []
		for i in range(0, n):
			b.append(a[i])
		for i in range(0, n):
			a[i] = b[a[i]]


class Solution:

	def prank(self, a, n):
		d = dict()
		for i in range(n):
			d[a[i]] = i
		l = [0] * n
		for i in range(n):
			l[d[i]] += a[i]
		for i in range(n):
			a[i] = l[i]
		return a


class Solution:

	def prank(self, a, n):
		l = a.copy()
		a.clear()
		for i in range(len(l)):
			a.append(l[l[i]])


class Solution:

	def prank(self, a, n):
		arr = []
		for i in range(n):
			arr.append(a[i])
		for i in range(n):
			a[i] = arr[arr[i]]


class Solution:

	def prank(self, a, n):
		for i in range(n):
			a[i] += a[a[i]] % n * n
		for j in range(n):
			a[j] = int(a[j] / n)
		return a[j]


class Solution:

	def prank(self, a, n):
		temp = [0] * n
		dic = {}
		for i in range(n):
			dic[a[i]] = i
		for i in range(n):
			ti = dic[i]
			temp[ti] = a[i]
		for i in range(n):
			a[i] = temp[i]


class Solution:

	def prank(self, a, n):
		arr = [None] * n
		for (i, j) in enumerate(a):
			arr[i] = a[j]
		a[:] = arr


class Solution:

	def prank(self, a, n):
		dic = {}
		for i in range(n):
			dic[a[i]] = i
		for (key, val) in dic.items():
			a[dic[val]] = key
		return a


class Solution:

	def prank(self, l, n):
		for i in range(n):
			l[i] = l[i] + (n + 1) * (l[l[i]] % (n + 1))
		for i in range(n):
			l[i] = int(l[i] / (n + 1))
		return l


class Solution:

	def prank(self, a, n):
		c = a.copy()
		d = {}
		for i in range(len(c)):
			d.update({c[i]: i})
		for x in range(len(c)):
			tar = d[x]
			a[tar] = c[x]


class Solution:

	def prank(self, a, n):
		ind_arr = [0] * n
		for (i, v) in enumerate(a):
			ind_arr[v] = i
		new_arr = [0] * n
		for i in range(n):
			new_arr[ind_arr[i]] = a[i]
		for i in range(n):
			a[i] = new_arr[i]


class Solution:

	def prank(self, a, n):
		y = dict()
		for i in range(n):
			y[i] = a[i]
		for i in range(n):
			a[i] = y[y[i]]


class Solution:

	def prank(self, a, n):
		ds = {}
		for i in range(n):
			ds[i] = a[i]
		for i in range(n):
			a[i] = ds.get(a[i])
		return a[i]


class Solution:

	def prank(self, arr, n):
		al = [None] * n
		for i in range(len(arr)):
			al[i] = arr[arr[i]]
		arr.clear()
		arr += al


class Solution:

	def prank(self, a, n):
		temp = [1] * n
		for i in range(n):
			temp[i] = a[a[i]]
		print(*temp)


class Solution:

	def prank(self, a, n):
		positions = {}
		for i in range(len(a)):
			positions[a[i]] = i
		for i in range(len(a)):
			if a[i] == i or i != positions[a[i]]:
				continue
			else:
				self.walk(positions, a, i)
		return a

	def walk(self, positions, arr, start):
		curr = start
		firstTime = True
		currEle = arr[start]
		nextIndex = positions[start]
		while curr != start or firstTime:
			firstTime = False
			nextEle = arr[nextIndex]
			arr[nextIndex] = currEle
			curr = nextIndex
			nextIndex = positions[nextIndex]
			currEle = nextEle
		return


class Solution:

	def prank(self, a, n):
		for (i, e) in enumerate(a):
			a[i] += a[a[i]] % n * n
		for (i, e) in enumerate(a):
			a[i] = a[i] // n


class Solution:

	def prank(self, a, n):
		D = {}
		for i in range(n):
			D[a[i]] = i
		ans = [0] * n
		for j in range(n):
			ans[D[j]] = a[j]
		a[:] = ans
		return a


class Solution:

	def prank(self, a, n):
		lst = [i for i in a]
		for i in range(n):
			lst[i] = a[a[i]]
		a[:] = lst[:]
		return a


class Solution:

	def prank(self, a, n):
		aa = a[:]
		roll_desk = {a[i]: i for i in range(n)}
		for i in range(n):
			a[roll_desk[i]] = aa[i]