# Values from the challenge
n = 1079
e = 43
p = 13  # Smaller prime
q = 83  # Larger prime
c_list = [996, 894, 379, 631, 894, 82, 379, 852, 631, 677, 677, 194, 893]

# Step 1: Calculate Phi(n)
phi = (p - 1) * (q - 1)

# Step 2: Calculate the private key 'd' 
# Using pow() with -1 calculates the modular multiplicative inverse
d = pow(e, -1, phi)

# Step 3: Decrypt each character
plaintext = ""
for c in c_list:
    m = pow(c, d, n)
    plaintext += chr(m)

print(f"Private Key (d): {d}")
print(f"Decrypted Message: {plaintext}")
