def power(a, n, M):

    if n == 0: return 1

    tmp = power(a*a%M, n/2, M)

    if n % 2 == 1:

        tmp = tmp * a % M

    return tmp

m, n = list(map(int, input().split()))

print(power(m, n, 1000000007))
def power(a, n, M):

    res = 1

    if n > 0:

        res = power(a*a%M, n/2, M)

        if n % 2 == 1:

            res = res * a % M

    return res

m, n = list(map(int, input().split()))

print(power(m, n, 1000000007))
def power(a, n, M):
    if n == 0:
        return 1
    tmp = power(a * a % M, n / 2, M)
    if n % 2 == 1:
        tmp = tmp * a % M
    return tmp


m, n = list(map(int, input().split()))
print(power(m, n, 1000000007))

def power(a, n, M):
    res = 1
    if n > 0:
        res = power(a * a % M, n / 2, M)
        if n % 2 == 1:
            res = res * a % M
    return res


m, n = list(map(int, input().split()))
print(power(m, n, 1000000007))

-    if n == 0: -        return 1 -    tmp = power(a * a % M, n / 2, M) -    if n % 2 == 1: -        tmp = tmp * a % M -    return tmp +    res = 1 +    if n > 0: +        res = power(a * a % M, n / 2, M) +        if n % 2 == 1: +            res = res * a % M +    return res