Given a number N, generate all the possible cyclic permutations of the number.
Example 1:
Input:
N = 123
Output:
123 312 231
Explanation:
For 123 there are 3 cyclic permutations possible.
Example 2:
Input:
N = 5674
Output:
5674 4567 7456 6745
Explanation:
For 5674 there are 4 cyclic permutations possible.
Your Task:  
You don't need to read input or print anything. Your task is to complete the function cyclicPermutations() which takes an integer N as input parameter and returns the list of unique cyclic permutations of N.
Note: Cyclic permutation should not contain leading zeros
Expected Time Complexity: O(X)
Expected Auxiliary Space: O(X), Where X is the number of the digit of N.
Constraints: 
1 <= N <= 10^{9}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(X)
Expected Auxiliary Space: O(X), Where X is the number of the digit of N.

Starter code:
#User function Template for python3



class Solution:

    def cyclicPermutations(self, N):

    	#code here 

Solutions:
class Solution:

	def cyclicPermutations(self, N):
		l = [N]
		i = 1
		ln = len(str(N))
		mul = 10 ** (ln - 1)
		while i < ln:
			v = l[len(l) - 1]
			rem = v % 10
			qu = v // 10
			ans = mul * rem + qu
			if ans in l:
				break
			else:
				l.append(ans)
				i += 1
		return l


class Solution:

	def cyclicPermutations(self, N):
		ans = []
		s = str(N)
		for i in range(len(s)):
			current = [i for i in s]
			for j in range(i):
				current.insert(0, current.pop())
			t = int(''.join(current))
			if t not in ans:
				ans.append(t)
		return ans


class Solution:

	def cyclicPermutations(self, N):
		n = []
		if N >= 0 and N <= 9:
			return [N]
		c = str(N)[-1] + str(N)[:-1]
		n.append(N)
		while int(c) != N:
			n.append(int(c))
			b = str(c)[-1] + str(c)[:-1]
			c = b
		return n


class Solution:

	def cyclicPermutations(self, N):
		s = str(N)
		arr = [N]
		for i in range(len(s)):
			s = s[-1] + s[:len(s) - 1]
			if int(s) not in arr:
				arr.append(int(s))
		return arr


class Solution:

	def cyclicPermutations(self, N):
		num = str(N) * len(str(N))
		length = len(str(N))
		new_list = []
		j = 0
		for i in range(length):
			new_num = int(num[j:j + length])
			if new_num not in new_list:
				new_list.append(new_num)
			j += length - 1
		return new_list


class Solution:

	def cyclicPermutations(self, N):
		N = str(N)
		l = [N]
		n = len(N)
		for i in range(n - 1):
			N = N[n - 1] + N[:n - 1]
			l.append(N)
		b = []
		s = {}
		for i in range(n):
			l[i] = l[i].lstrip('0')
			if l[i] not in s:
				s[l[i]] = 1
				b.append(l[i])
		return b


class Solution:

	def countdigit(self, N):
		count = 0
		while N > 0:
			count += 1
			N = N // 10
		return count

	def cyclicPermutations(self, N):
		ls = []
		num = N
		count = self.countdigit(N)
		while True:
			ls.append(num)
			rem = num % 10
			dev = num // 10
			num = int(pow(10, count - 1) * rem + dev)
			if num == N:
				break
		return ls
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		ans = ob.cyclicPermutations(N)
		for i in ans:
			print(i, end=' ')
		print()


class Solution:

	def cyclicPermutations(self, N):
		l = [N]
		m = str(N)
		n = list(str(N))
		j = len(n)
		for i in range(j):
			x = n[j - 1]
			n.pop(j - 1)
			n.insert(0, x)
			if ''.join(n) != m:
				if int(''.join(n)) not in l:
					l.append(int(''.join(n)))
		return l