# import numpy as np
# import decimal
# decimal.getcontext().prec = 100000
# a, n = map(decimal.Decimal, input().split())
# # m = 10 ** 7
# m = 998244353
# print(m)
# q, r = np.divmod(np.power(a,n), m)
# print(r)

m = 1000000007
# m = 998244353
def modpow(a,n,mod):
    res = 1
    while n > 0:
        if n & 1:
            res = int(res * a % mod)
        a = int(a * a % mod) 
        n = n >> 1
    return res

a, n = map(int, input().split())
print(m)
print(modpow(a, n, m))