def char_to_dez(char=""):
    if char == " ":
        return "32"
    elif char == "!":
        return "33"
    elif char == '"':
    	return "34"
    elif char == "#":
    	return "35"
    elif char == "$":
    	return "36"
    elif char == "%":
    	return "37"
    elif char == "&":
    	return "38"
    elif char == "'":
    	return "39"
    elif char == "(":
    	return "40"
    elif char == ")":
    	return "41"
    elif char == "*":
    	return "42"
    elif char == "+":
    	return "43"
    elif char == ",":
    	return "44"
    elif char == "-":
    	return "45"
    elif char == ".":
    	return "46"
    elif char == "/":
    	return "47"
    elif char == "0":
    	return "48"
    elif char == "1":
    	return "49"
    elif char == "2":
    	return "50"
    elif char == "3":
    	return "51"
    elif char == "4":
    	return "52"
    elif char == "5":
    	return "53"
    elif char == "6":
    	return "54"
    elif char == "7":
    	return "55"
    elif char == "8":
    	return "56"
    elif char == "9":
    	return "57"
    elif char == ":":
    	return "58"
    elif char == ";":
    	return "59"
    elif char == "<":
    	return "60"
    elif char == "=":
    	return "61"
    elif char == ">":
    	return "62"
    elif char == "?":
    	return "63"
    elif char == "@":
    	return "64"
    elif char == "A":
    	return "65"
    elif char == "B":
    	return "66"
    elif char == "C":
    	return "67"
    elif char == "D":
    	return "68"
    elif char == "E":
    	return "69"
    elif char == "F":
    	return "70"
    elif char == "G":
    	return "71"
    elif char == "H":
    	return "72"
    elif char == "I":
    	return "73"
    elif char == "J":
    	return "74"
    elif char == "K":
    	return "75"
    elif char == "L":
    	return "76"
    elif char == "M":
    	return "77"
    elif char == "N":
    	return "78"
    elif char == "O":
    	return "79"
    elif char == "P":
    	return "80"
    elif char == "Q":
    	return "81"
    elif char == "R":
    	return "82"
    elif char == "S":
    	return "83"
    elif char == "T":
    	return "84"
    elif char == "U":
    	return "85"
    elif char == "V":
    	return "86"
    elif char == "W":
    	return "87"
    elif char == "X":
    	return "88"
    elif char == "Y":
    	return "89"
    elif char == "Z":
    	return "90"
    elif char == "[":
    	return "91"
    elif char == "\\":
    	return "92"
    elif char == "]":
    	return "93"
    elif char == "^":
    	return "94"
    elif char == "_":
    	return "95"
    elif char == "`":
    	return "96"
    elif char == "a":
    	return "97"
    elif char == "b":
    	return "98"
    elif char == "c":
    	return "99"
    elif char == "d":
    	return "100"
    elif char == "e":
    	return "101"
    elif char == "f":
    	return "102"
    elif char == "g":
    	return "103"
    elif char == "h":
    	return "104"
    elif char == "i":
    	return "105"
    elif char == "j":
    	return "106"
    elif char == "k":
    	return "107"
    elif char == "l":
    	return "108"
    elif char == "m":
    	return "109"
    elif char == "n":
    	return "110"
    elif char == "o":
    	return "111"
    elif char == "p":
    	return "112"
    elif char == "q":
    	return "113"
    elif char == "r":
    	return "114"
    elif char == "s":
    	return "115"
    elif char == "t":
    	return "116"
    elif char == "u":
    	return "117"
    elif char == "v":
    	return "118"
    elif char == "w":
    	return "119"
    elif char == "x":
    	return "120"
    elif char == "y":
    	return "121"
    elif char == "z":
    	return "122"
    elif char == "{":
    	return "123"
    elif char == "|":
    	return "124"
    elif char == "}":
    	return "125"
    elif char == "~":
    	return "126"


def dez_to_char(dez=""):
    if dez == "32":
        return " "
    elif dez == "33":
        return "!"
    elif dez == "34":
        return '"'
    elif dez == "35":
        return "#"
    elif dez == "36":
    	return "$"
    elif dez == "37":
    	return "%"
    elif dez == "38":
    	return "&"
    elif dez == "39":
    	return "'"
    elif dez == "40":
    	return "("
    elif dez == "41":
    	return ")"
    elif dez == "42":
    	return "*"
    elif dez == "43":
    	return "+"
    elif dez == "44":
    	return ","
    elif dez == "45":
    	return "-"
    elif dez == "46":
    	return "."
    elif dez == "47":
    	return "/"
    elif dez == "48":
    	return "0"
    elif dez == "49":
    	return "1"
    elif dez == "50":
    	return "2"
    elif dez == "51":
    	return "3"
    elif dez == "52":
    	return "4"
    elif dez == "53":
    	return "5"
    elif dez == "54":
    	return "6"
    elif dez == "55":
    	return "7"
    elif dez == "56":
    	return "8"
    elif dez == "57":
    	return "9"
    elif dez == "58":
    	return ":"
    elif dez == "59":
    	return ";"
    elif dez == "60":
    	return "<"
    elif dez == "61":
    	return "="
    elif dez == "62":
    	return ">"
    elif dez == "63":
    	return "?"
    elif dez == "64":
    	return "@"
    elif dez == "65":
    	return "A"
    elif dez == "66":
    	return "B"
    elif dez == "67":
    	return "C"
    elif dez == "68":
    	return "D"
    elif dez == "69":
    	return "E"
    elif dez == "70":
    	return "F"
    elif dez == "71":
    	return "G"
    elif dez == "72":
    	return "H"
    elif dez == "73":
    	return "I"
    elif dez == "74":
    	return "J"
    elif dez == "75":
    	return "K"
    elif dez == "76":
    	return "L"
    elif dez == "77":
    	return "M"
    elif dez == "78":
    	return "N"
    elif dez == "79":
    	return "O"
    elif dez == "80":
    	return "P"
    elif dez == "81":
    	return "Q"
    elif dez == "82":
    	return "R"
    elif dez == "83":
    	return "S"
    elif dez == "84":
    	return "T"
    elif dez == "85":
    	return "U"
    elif dez == "86":
    	return "V"
    elif dez == "87":
    	return "W"
    elif dez == "88":
    	return "X"
    elif dez == "89":
    	return "Y"
    elif dez == "90":
    	return "Z"
    elif dez == "91":
    	return "["
    elif dez == "92":
    	return "\\"
    elif dez == "93":
    	return "]"
    elif dez == "94":
    	return "^"
    elif dez == "95":
    	return "_"
    elif dez == "96":
    	return "`"
    elif dez == "97":
    	return "a"
    elif dez == "98":
    	return "b"
    elif dez == "99":
    	return "c"
    elif dez == "100":
    	return "d"
    elif dez == "101":
    	return "e"
    elif dez == "102":
    	return "f"
    elif dez == "103":
    	return "g"
    elif dez == "104":
    	return "h"
    elif dez == "105":
    	return "i"
    elif dez == "106":
    	return "j"
    elif dez == "107":
    	return "k"
    elif dez == "108":
    	return "l"
    elif dez == "109":
    	return "m"
    elif dez == "110":
    	return "n"
    elif dez == "111":
    	return "o"
    elif dez == "112":
    	return "p"
    elif dez == "113":
    	return "q"
    elif dez == "114":
    	return "r"
    elif dez == "115":
    	return "s"
    elif dez == "116":
    	return "t"
    elif dez == "117":
    	return "u"
    elif dez == "118":
    	return "v"
    elif dez == "119":
    	return "w"
    elif dez == "120":
    	return "x"
    elif dez == "121":
    	return "y"
    elif dez == "122":
    	return "z"
    elif dez == "123":
    	return "{"
    elif dez == "124":
    	return "|"
    elif dez == "125":
    	return "}"
    elif dez == "126":
    	return "~"


def int_to_str(x_p=0):
    x = str(bin(x_p))[2:]
    x = ("0" * ((8 - (len(x) % 8)))) + x
    # print(len(x))
    ans = []
    while len(x) >= 8:
        ans = [""] + ans
        for i in range(8):
            ans[0] = x[-1] + ans[0]
            x = x[:-1]
    res = ""
    for i in range(len(ans)):
        ans[i] = [0, list(ans[i])]
        for i2 in range(8):
            if ans[i][1][-1] == "1":
                ans[i][0] = ans[i][0] + (2 ** (i2))
            ans[i][1] = ans[i][1][:-1]
        # res = res + dez_to_char(str(ans[i][0]))
        # ans[i] = ans[i][0]
        # ans[i] = dez_to_char(str(ans[i]))
        # res = res + ans[i]
    # print("ans:", ans)
    for i in range(len(ans)):
        res = res + dez_to_char(str(ans[i][0]))
    # print("ans:", ans)
    return res


def hexbyte_to_int(hex_p=""):
    x = list(hex_p)
    symbols = list("0123456789abcdef")
    ans = ""
    for i in range(len(x)):
        x[i] = x[i].lower()
        foo = str(bin(symbols.index(x[i])))[2:]
        ans = ans + ("0" * (4 - len(foo))) + foo
    ans = int(str(int(ans, 2)))
    return ans


def ctf4(x_p=0):
    x = hex(x_p)[2:]
    print(x)
    l = []
    while len(x) > 0:
        l.append(x[-2:])
        x = x[:-2]
    l.reverse()
    print(l)
    ans = ""
    for i in range(len(l)):
        ans = ans + chr(int(l[i], 16))
    return ans