from Crypto.Util.number import * # type: ignore
from pwn import * # type: ignore

r = remote("localhost",10001)
r.recvline()
n = r.recvline()
n = int(n.decode())

r.recvline()
c = r.recvline()
c = int(c.decode())

r.recvline()
d = r.recvline()
d = int(d.decode())

m = pow(c, d, n)
print(long_to_bytes(m))