For any positive integer, we define a digit rotation as either moving the first digit
to the end of the number (left digit rotation), or the last digit to the front of the number (right digit rotation).
For example, the number 12345 could be left digit rotated to 23451, or right digit rotated to 51234.
If there are any leading zeros after digit rotation, they must be removed.
So 10203 could be left digit rotated to 2031, then left digit rotated again to 312.
Given an integer N, determine the largest integer that can result from performing a series of one or more
digit rotations on N.

------ Input ------ 

Input will begin with an integer T (at most 1000), the number of test cases.
Each test case consists of a positive integer N<100000000 (10^{8}) on a line by itself.

------ Output ------ 

For each test case, print the largest integer that can result from performing one or more
digit rotations on N.

----- Sample Input 1 ------ 
6
12345
54321
10901
211011
7
90
----- Sample Output 1 ------ 
51234
54321
11090
211011
7
9

Difficulty: MEDIUM_HARD

Solutions:
t = int(input())
for i in range(t):
	num = int(input().strip())
	num = str(num)
	orgNum = num
	temp = []
	numLeft = num[1:] + num[0]
	num = str(int(numLeft))
	numRight = num[-1] + num[:-1]
	num = str(int(numRight))
	temp += [int(num)]
	num = orgNum
	numRight = num[-1] + num[:-1]
	num = str(int(numRight))
	numLeft = num[1:] + num[0]
	num = str(int(numLeft))
	temp += [int(num)]
	num = orgNum
	for j in range(len(num)):
		numLeft = num[1:] + num[0]
		num = str(int(numLeft))
		temp += [int(num)]
	num = orgNum
	for j in range(len(num)):
		numRight = num[-1] + num[:-1]
		num = str(int(numRight))
		temp += [int(num)]
	print(max(temp))


def leftRotation(num):
	strNum = str(num)
	return int(strNum[1:] + strNum[0])

def rightRotation(num):
	strNum = str(num)
	l = len(strNum)
	return int(strNum[l - 1] + strNum[0:l - 1])
t = int(input())
for _ in range(t):
	num = int(input())
	noOfDigits = len(str(num))
	maximum = -1
	lnum = num
	rnum = num
	copyNum = num
	for i in range(noOfDigits - 1):
		lnum = leftRotation(lnum)
		rnum = rightRotation(rnum)
		maximum = max(maximum, lnum)
		maximum = max(maximum, rnum)
	copyNum = leftRotation(copyNum)
	copyNum = rightRotation(copyNum)
	maximum = max(maximum, copyNum)
	copyNum = num
	copyNum = rightRotation(copyNum)
	copyNum = leftRotation(copyNum)
	maximum = max(maximum, copyNum)
	print(maximum)


def snek1(n):
	x = str(n)
	return int(x[1:] + x[0])

def snek2(n):
	x = str(n)
	z = len(x)
	return int(x[z - 1] + x[0:z - 1])
t = int(input())
for i in range(t):
	n = int(input())
	s = len(str(n))
	m = -1
	(l, r, c) = (n, n, n)
	for j in range(s - 1):
		l = snek1(l)
		r = snek2(r)
		m = max(m, l)
		m = max(m, r)
	c = snek1(c)
	c = snek2(c)
	m = max(m, c)
	c = n
	c = snek2(c)
	c = snek1(c)
	m = max(m, c)
	print(m)


def rotateLeft(n):
	n = str(n)
	n = n[1:] + n[0]
	return int(n)

def rotateRight(n):
	n = str(n)
	n = n[-1] + n[:-1]
	return int(n)

def bestRotation(n):
	visited.add(n)
	(leftChild, rightChild) = (rotateLeft(n), rotateRight(n))
	if leftChild not in visited:
		bestRotation(leftChild)
	if rightChild not in visited:
		bestRotation(rightChild)
testCases = int(input())
for case in range(testCases):
	visited = set()
	source = int(input())
	bestRotation(rotateLeft(source))
	bestRotation(rotateRight(source))
	print(max(visited))


def rotL(n):
	x = str(n)
	return int(x[1:] + x[0])

def rotR(n):
	x = str(n)
	return int(x[-1] + x[0:-1])
for i in range(int(input())):
	n = int(input())
	s = len(str(n))
	m = -1
	(l, r, c) = (n, n, n)
	for j in range(s - 1):
		l = rotL(l)
		r = rotR(r)
		m = max(m, l)
		m = max(m, r)
	c = rotL(c)
	c = rotR(c)
	m = max(m, c)
	c = n
	c = rotR(c)
	c = rotL(c)
	m = max(m, c)
	print(m)