import string;from binascii import *\x0d e=raw_input();s=raw_input()\x0d if e[0]=="e":o=string.upper(b2a_hex(s))\x0d else:o=a2b_hex(s)\x0d if s[len(s)-1]=='4':o+='A'\x0d print o\x0d
Note that non-ascii characters in the above source code will be escaped (such as \x9f).