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:
t=input()
for i in range(0,t):
    s=raw_input()
    w=0
    for j in range(0,len(s)):
        w+=ord(s[j])
    f= int(w/len(s))
    if f%2==0:
        print s
    else:
        print s[::-1]