T : Number of test cases
M: value of M
N: Number of strings
For each string, ascii value of each character of the string is raised to M and multiplied together. For each test case the sum of above values is ODD or EVEN
TIP: Challenge lies in finding the solution without doing all the mathematical operations mentioned in the question. (yes, also called optimizing..!)
#!/usr/bin/python T = int(raw_input()) while T>0: T = T - 1 tmp = raw_input() M = int(tmp.split()) K = int(tmp.split()) tmp = raw_input() final_odd = False for s in tmp.split(): odd = None for i in s: if ord(i)%2==0: # the power is even odd = False else: # the power is odd if odd==None: # if odd is True, odd*odd=odd odd = True # odd + odd = even # odd + even = odd # even + even = even if final_odd != odd: final_odd = True else: final_odd = False if final_odd: print "ODD" else: print "EVEN"