Problem: Xavier asks his friend to perform a particular task.The task is to find out the ASCII value of each character of a given STRING and then add them up to find the weight of the given string as 'W',now after finding out the weight his task is to divide the weight of string W with the length of string 'L'such that the final answer is 'F' rounded of to previous integer value in case of float or double value.

Now Xavier introduces a twist in the tail the twist seems to be as follows:-

1.If 'F' is odd then to needs to find out reverse of the given string.For eg:- if 'F'
  is 109 and input string is xyzabc the output must be cbazyx.

2.If 'F' is even then print the original string.

INPUT

First line inputs the no of test cases T.

Second line inputs the string on which the task is to be performed.

OUTPUT

T no of outputs according to the above task.

Constraints

T ≤ 100.
L ≤ 100.

SAMPLE INPUT
1
xyzabc

SAMPLE OUTPUT
cbazyx

Explanation

The input string is "xyzabc"
then,

The ASCII value of x is 120. 

The ASCII value of y is 121.

The ASCII value of z is 122.

The ASCII value of a is 97.

The ASCII value of b is 98.

The ASCII value of c is 99.

W=657.

F=109.

So output="cbazyx".

Solution (in PYTHON):

Solution:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

n = int(raw_input())
for i in range(n):
	tc = list(raw_input())
	# tc = [x for x in tc if x != ' ']
	ans = 0
	for j in tc:
		ans += ord(j)
	
	ans /= len(tc)
	
	if ans % 2 == 0:
		print ''.join(tc)
	else:
		print ''.join(tc[::-1])