import json
import base64

modulus = 93749
def encrypt(message, n, k):
    return message**k % n

alphabet = {"A": 1, "B": 2, "C":3, "D":4, "E":5, "F":6, "G":7,"H": 8,"I":9,"J":10,"K":11,"L":12,"M":13,"N":14,"O":15,"P":16,"Q":17,"R":18,"S":19,"T":20,"U":21,"V":22,"W":23,"X":24,"Y":25,"Z":26," ":27}
def encrypt_text(text):
    output = []
    for char in text:
        output.append(encrypt(alphabet[char.upper()], modulus, public))
    json_list = json.dumps(output)
    encoded = base64.b64encode(json_list.encode("ascii"))
    return encoded

text = input("Enter text: ")
public = int(input("Enter public key: "))
output = encrypt_text(text)
print(str(output.decode('utf-8')))
