Problem:
Power For given integers m and n , compute m n (mod 1,000,000,007). Here, A (mod M ) is the remainder when A is divided by M . Input  m  n  Two integers m and n are given in a line. Output Print m n (mod 1,000,000,007) in a line. Constraints  1 ≤ m ≤ 100  1 ≤ n ≤ 10 9  Sample Input 1 2 3 Sample Output 1 8 Sample Input 2 5 8 Sample Output 2 390625

Solution (Python):
M, N = map(int, input().split())
mod = 1000000007

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


print(modpow(M, N, mod))

Solution (Python):
m, n = map(int, input().split())

ans = pow(m, n, 1000000007)

print(ans)

Solution (Python):
p = 1000000007
def modPow(a, n, m):
    ans = 1
    while n > 0:
        if (n & 1): ans = (ans * a) % m
        a = (a * a) % m
        n = n >> 1
    return ans

n, m = map(int, input().split())
print(modPow(n, m, p))

Solution (Python):
m, n = [int(arg) for arg in input().split()]
print(pow(m, n, 1000000007))

Solution (Python):
mod = 10**9+7

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

ans = pow(m,n,mod)
print(ans)

Solution (Python):

a,b = map(int,input().split())


print(pow(a,b,1000000007))

Solution (Python):
m, n = map(int, input().split())
x = 1000000007
print(pow(m,n,x))

Solution (Python):
x = 1000000007
m,n=map(int,input().split())
print(pow(m,n,x))

Solution (Python):

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

mod = 10**9 + 7

res = pow(m, n, mod)

print(res)

Solution (Python):
def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

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

mod=10**9+7

print(power(m,n))

Solution (Python):
n,m = map(int,input().split())
print(pow(n,m,1000000007))

Solution (Python):


from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

MOD = 1000000007
m, n = map(int, input().split())


def pow_fast(m, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return pow_fast(m * m % MOD, n / 2)
    else:
        return pow_fast(m * m % MOD, int(n / 2)) * m % MOD


print(pow_fast(m, n))

Solution (Python):
m, n = map(int, input().split())
print(pow(m,n,10**9+7))

Solution (Python):
mod = 10**9 + 7

def pow(x, y):
    ret = 1
    while y:
        if y & 1:
            ret = ret * x % mod
        x = x * x % mod
        y >>= 1
    
    return ret

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

Solution (Python):
def pow(a, n, MOD=1):
    """
    繰り返し二乗法 (半分の数の 2 乗) / 自乗
    Compute nth power of a -- O(logn)
    """
    if n == 0:
        return 1
    x = pow(a, n//2, MOD)
    x = (x%MOD * x%MOD) % MOD
    if n%2 == 1:
        x = (x%MOD * a%MOD) % MOD
    return x


MOD = 1_000_000_007
m, n = map(int, input().split())
print(pow(m, n, MOD))

Solution (Python):
m,n=map(int,input().split())
p=pow(m,n,1000000007)
print(p)

Solution (Python):
import math

def power2(n):
  global ans
  if n == 1:
    tmp =  m % p
  elif n % 2 == 0:
    tmp = power2(n//2) ** 2 % p
  else:
    tmp =  power2(n//2) * power2((n+1)//2) % p
  return ans * tmp % p
    
m, n = map(int, input().split())
p = 10**9+7
ans = 1
print(power2(n))

Solution (Python):
a,x = map(int, input().split())
n = 1000000007
print(pow(a, x, n))

Solution (Python):
m, n = map(int, input().split())
mod = 1000000007

print(pow(m, n, mod))

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,10**9+7))

Solution (Python):
m, n = map(int, input().split())
mod = 1000000007
print(pow(m, n, mod))

Solution (Python):
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
MOD = 1000000007
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    m, n = LI()

    
    def f(m, n, p):
        if n==1:
            return m
        else:
            if n%2==0:
                return (f(m, n//2, p)**2) % p
            else:
                return (f(m, n//2, p)**2*m) % p
    print(f(m, n, MOD))

if __name__ == '__main__':
    resolve()

Solution (Python):

M,N = map(int,input().split())
mod = 10**9+7
print(pow(M, N, mod))

Solution (Python):
m,n=map(int,input().split())

print(pow(m,n,1000000007))

Solution (Python):
m,n = map(int,input().split())
MOD = 10**9+7
a = pow(m,n,MOD)
print(a)

Solution (Python):

import sys
m, n = map(int, sys.stdin.readline().strip().split())

mod = 10**9 + 7

print(pow(m, n, mod))

Solution (Python):

import math











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

res = 1
mod = 10 ** 9 + 7
while n > 0:
    if n & 1 == 1:
        res = res * m % mod
    m = m * m % mod

    n >>= 1

print(res)

Solution (Python):
import sys,bisect,math
sys.setrecursionlimit(15000)

M,N = map(int,sys.stdin.readline().split())

def powmod(m,n,mod):
  if n == 1:
    return m
  ret = (powmod(m*m%mod,n//2,mod))%mod
  if n%2==1:
    return (ret*m)%mod
  return ret%mod

print(powmod(M,N,1000000007))

Solution (Python):
import sys

m, n = map(int, sys.stdin.readline().strip().split())
print(pow(m, n, 10**9 + 7))

Solution (Python):
mod = 10**9+7
def power(m, n):
    if n == 0:
        return 1
    res = power(m*m%mod, n//2)
    if n%2 == 1:
        res = res*m%mod
    return res

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

Solution (Python):
m, n = map(int, input().split())
MOD = 10 ** 9 + 7
print(pow(m, n, MOD))

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
m, n = map(int, input().split())
mod = 10**9 + 7
print(pow(m, n, mod))

Solution (Python):
m,n = map(int,input().split())
mod = 10**9+7


def power(x,n,m):
    res = 1
    if n > 0:
        res = power(x,n//2,m)
        if n%2 == 0: res = res*res%m
        else: res = res*res%mod*x%m
    return res

print(power(m,n,mod))

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    m,n = map(int, readline().split())

    MOD = 10**9+7
    print(pow(m, n, MOD))


if __name__ == "__main__":
    main()

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

def mod_pow(a,n,mod):
    ret = 1
    while n>0:
        if (n & 1): ret = ret * a % mod
        a = a * a % mod
        n >>= 1
    return ret

print(mod_pow(m,n,10**9+7))

Solution (Python):
MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res
    
m, n = list(map(int, input().split()))
print(pow(m, n))

Solution (Python):
MOD = 1_000_000_007
m, n = map(int, input().split())

def modpower_rec(a, b, M=MOD):
    
    if b <= 8:
        return (a ** b) % M
    else:
        if b % 2 == 0:
            return modpower_rec(a ** 2, b // 2, M)
        else:
            return (modpower_rec(a ** 2, b // 2, M) * a) % M


def modpower_rec2(a, b, M=MOD):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return modpower_rec2((a ** 2) % M, b // 2) % M
    else:
        return (modpower_rec2((a ** 2) % M, b // 2) * a) % M


def mpower(a, b, M=MOD):
    rem = 1
    while b > 0:
        if b % 2 == 1:
            rem = rem * a % M
        a = a ** 2 % M
        b //= 2
    return rem % M



print(mpower(m, n, MOD))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10**9+7))

Solution (Python):
m,n = map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
MOD=1000000007

def log_n_power(m,n,mod):
    if n==0:
        return 1
    elif n%2:
        k=log_n_power(m,n//2,mod)
        return k*k*m%mod
    else:
        k=log_n_power(m,n//2,mod)
        return k*k%mod

def main():
    m,n=map(int,input().split())
    print(log_n_power(m,n,MOD))

main()

Solution (Python):
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

m,n=map(int,input().split())
print(modpow(m,n,10**9+7))

Solution (Python):
MOD = 10 ** 9 + 7
m,n = map(int,input().split())

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % MOD
        x = x ** 2 % MOD
        n //= 2

    return K * x % MOD

print(pow_k(m,n))

Solution (Python):
m, n = map(int, input().split())
mod = 10**9 + 7
print(pow(m, n, mod))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10**9+7))

Solution (Python):
m,n = map(int,input().split())
mod = 10 ** 9 + 7

result = pow(m,n,mod)
print(result)

Solution (Python):
def pow_k(x, n, M):

    if n == 0:
        return 1

    K = 1
    while n:
        if n & 1:
            K *= x
            K %= M
        x *= x
        x %= M
        n >>= 1

    return K

M = 1000000007
m, n = map(int, input().split())
print(pow_k(m, n, M))

Solution (Python):
m,n=map(int, input().split())
MOD=10**9+7
ans = 1
t = m
while n:
    if n&1: ans = (ans*t)%MOD
    n >>= 1
    t = (t*t)%MOD
print(ans)

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 1000000007))

Solution (Python):
m, n = map(int, input().split())

P = 10 ** 9 + 7


def pow(x, n, p):
  r = 1
  while n > 0:
    if n & 1:
      r = (r * x) % p
    x = (x * x) % p
    n >>= 1
  return r

print(pow(m, n, P))

Solution (Python):
m,n=map(int,input().split())
mod=10**9+7
print(pow(m,n,mod))

Solution (Python):
m, n = map(int, input().split())
mod = 10 ** 9 + 7
ans = pow(m, n, mod)
print(ans)

Solution (Python):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def p(M, N, mod):
    if N == 0:
        return 1
    if N % 2 == 0:
        half = p(M, N // 2, mod)
        return half * half % mod
    else:
        return M * p(M, N - 1, mod) % mod


if __name__ == "__main__":
    M, N = map(int, input().split())
    mod = 1_000_000_007
    ans = p(M, N, mod)
    print(ans)

Solution (Python):
def mod_pow(m, n, mod):
    if n == 0:
        return 1
    if n == 1:
        return m % mod

    res = 1
    if n % 2 == 1:
        res = res * m

    return (res * (mod_pow((m * m) % mod, n // 2, mod)) % mod) % mod


mod = 10 ** 9 + 7
m, n = map(int, input().split())
print(mod_pow(m, n, mod))

Solution (Python):
m,n=map(int,input().split())
mod=10**9+7
print(pow(m,n,mod))

Solution (Python):
def rep_pow(a, k, p=10**9+7):
    
    ans = 1
    while k > 0:
        if k & 1:
            ans = ans * a % p
        a = a * a % p
        k >>= 1
    return ans

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

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,10**9+7))

Solution (Python):
n,m=map(int,input().split())
print(pow(n,m,1000000007)%1000000007)

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m,n = LI()
    print(pow(m,n,mod))
    return


if __name__ == "__main__":
    solve()

Solution (Python):
a,b = map(int,input().split())
m = pow(10,9)+7
print(pow(a,b,m))

Solution (Python):
def pow(m, n, mod):
    if n == 0:
        return 1
    elif n == 1:
        return m
    if n % 2 == 0:
        return pow(m, n // 2, mod) ** 2 % mod
    else:
        return pow(m, n // 2 + 1, mod) * pow(m, n // 2, mod) % mod




m, n = map(int, input().split())
mod = 10 ** 9 + 7

print(pow(m, n, mod))

Solution (Python):
MOD = 10**9 + 7
m ,n = map(int,input().split())
print (pow(m,n,MOD))

Solution (Python):
MOD = 10 ** 9 + 7
m, n = map(int, input().split())
print(pow(m, n, MOD))

Solution (Python):
m,n = map(int, input().split())
mod = 10**9+7
print(pow(m,n,mod))

Solution (Python):
m,n = map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
mod = 1000000007
l = input().split()
m = int(l[0])
n = int(l[1])


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y/2)**2 % mod
    else:
        return power(x, int(y/2))**2 * x % mod


ans = power(m, n)
print(ans)

Solution (Python):
m,n = map(int,input().split())
BIGNUM = 10**9+7

def power(m,n):
    if n == 0:
        return 1
    elif n % 2 == 1:
        return (m * power(m**2 % BIGNUM,n//2)) % BIGNUM
    else:
        return power(m**2 % BIGNUM,n//2) % BIGNUM

print(power(m,n))

Solution (Python):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


print(bpm(m, n, MOD))

Solution (Python):

m,n = map(int,input().split())
mod = 10 ** 9 + 7

ans = pow(m, n, mod)

print(ans)

Solution (Python):
MOD = 10**9 + 7

m, n = map(int, input().split())
print(pow(m, n, MOD))

Solution (Python):
MOD = 1000000007
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
    
    def __iadd__(self,other):
        self.x += other.x if isinstance(other, ModInt) else other
        self.x %= MOD
        return self

    def __isub__(self,other):
        self.x += ModInt(MOD - other.x) if isinstance(other, ModInt) else ModInt(MOD - other)
        return self

    def __imul__(self, other):
        self.x *= other.x if isinstance(other, ModInt) else other
        self.x %= MOD
        return self
    
    def factorical(self,n):
        tmp = ModInt(1)
        for i in range(n):
            tmp *= (i+1)
        return tmp
    
    
    def modinv(self,a,m=MOD):
        b = m
        u = 1
        v = 0
        while(b):
            t = a//b
            a -= t * b
            a,b = b,a
            u -= t * v
            u,v = v,u
        return ModInt(u)

    def comb(self,n,r):
        n = int(n)
        r = int(r)
        if r > n or n < 0 or r < 0:
            return 0
        m = n+1
        nterms = min(r, n-r)
        numerator = ModInt(1)
        denominator = ModInt(1)
        for j in range(1, nterms + 1):
            numerator *= m - j
            denominator *= j
        return numerator * self.modinv(denominator.x)
        
if __name__ == "__main__":
    x,y=map(int,input().split())
    a = ModInt(x)
    b = ModInt(y)
    print(pow(a,b))

Solution (Python):


mod=1e9+7
mod=int(mod)
def pow(a,b):
    
    
    if(b==0):
        return 1
    temp=pow(a,b//2)%mod
    temp=(temp**2)%mod
    if b%2==0:
        return temp%mod
    else:
        return (temp*a)%mod

a,b=map(int,input().split())
print(pow(a,b)%mod)

Solution (Python):
MOD = 1000000007
m,n = map(int,input().split())
print(pow(m,n,MOD))

Solution (Python):
m,n = map(int, input().split())
print(pow(m,n, 1000000007))

Solution (Python):
from functools import lru_cache
mod=1000000007

m,n=[int(i) for i in input().split(" ")]

@lru_cache()
def power(m,n,mod):
    if n==0:
        return 1
    elif n==1:
        return m
    elif n%2==0:
        return ((power(m,n//2,mod)%mod) * (power(m,n//2,mod)%mod))%mod
    else:
        return (power(m,n-1,mod)*m)%mod

print(power(m,n,mod))

Solution (Python):
n,m=map(int,input().split())

print(pow(n,m,10**9+7))

Solution (Python):
a,b = map(int,input().split())
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x
print(pow(a,b,1000000007))

Solution (Python):



def pow(x, n):
    if n == 0:
        return 1
    res = pow(x * x % A, n // 2)
    if n % 2 == 1:
        res = res * x % A
    return res

nums=list(map(int,input().split()))
M  = nums[0]
N = nums[1]
A = 1000000007
print(pow(M, N))

Solution (Python):
mod=10**9+7
n,m=map(int,input().split())
def mypow(a,b):
	
	if b==0:
		return 1
	res=mypow(a**2%mod,b//2)
	if b%2==0:
		return res
	else:
		return res*a%mod
print(mypow(n,m))

Solution (Python):



MOD = 10**9 + 7
a, b = list(map(int, input().split()))
print(pow(a, b, MOD))

Solution (Python):
mod=10**9+7

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








def pow(m,n,mod):
    rem=1
    while n>0:
        if n%2==1:
            rem=rem*m%mod
        m=m**2%mod
        n//=2
    return rem%mod

print(pow(m,n,mod))

Solution (Python):

def npmodm(n,p,m):
    if p == 0:
        return 1
    elif p % 2 == 0:
        a = npmodm(n,p//2,m) % m
        return (a*a) % m
    else:
        a = npmodm(n,p-1,m) % m
        return (a*n) % m

m = 10**9+7
n,p = map(int,input().split())
print(npmodm(n,p,m))

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    m,n = list(map(int, input().split()))
    md=10**9+7
    print(pow(m,n,md))
main()

Solution (Python):
m, n = map(int, input().split())
ans = pow(m, n, 1000000007)
print(ans)

Solution (Python):

import math
mod = 10**9+7
m,n = map(int,input().split()) 
n2 = math.ceil(math.sqrt(n))

b = bin(n)
b = b.lstrip("0b")
blist = list(b)
blist = blist[::-1]
ans = 1
beki = [m]
for i in range(n2):
    m = (m**2)%mod
    beki.append(m)

blen = len(blist)
ans = 1
for i in range(blen):
    if blist[i] == "1":
        ans*=beki[i]
        ans%=mod
        
print(ans)

Solution (Python):
m, n = map(int, input().split())
LN = 1000000007

def pwr(p, q):
    if q == 1:
        return p%LN
    elif q % 2 == 0:
        return (pwr(p, q//2)%LN)**2%LN
    else:
        return (pwr(p, q//2)%LN)**2*p%LN

print(pwr(m, n))

Solution (Python):
m, n = map(int, input().split())

print(pow(m,n, 1000000007))

Solution (Python):
a,b=map(int,input().split());print(pow(a,b,10**9+7))

Solution (Python):
m, n = map(int, input().split())
MOD = 10**9 + 7
print(pow(m, n, MOD))

Solution (Python):
def power(m, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        k = power(m, n // 2)
        return k * k % 1000000007
    else:
        k = power(m, (n - 1) // 2)
        return k * k * m % 1000000007


m, n = [int(x) for x in input().split()]
print(power(m, n))

Solution (Python):
m,n = map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
import sys
import math
i=list(map(int,input().split()))
m=i[0]
n=i[1]
k=1000000007
def pw(m,n):
  if n==0:
    return 1
  elif n==1:
    return m%k
  else:
    if n%2==0:
      return pw(m,n//2)**2%k
    elif n%2==1:
      return (pw(m,n//2)**2*m)%k
    
print(pw(m,n))

Solution (Python):
def power(m: int, n: int) -> int:
    modulo = 10 ** 9 + 7
    if n == 0:
        return 1
    elif n == 1:
        return m
    elif n % 2 == 0:
        return power(m, n // 2) ** 2 % modulo
    else:
        return power(m, n // 2) ** 2 * m % modulo


if __name__ == "__main__":
    m, n = map(lambda x: int(x), input().split())
    print(f"{power(m, n)}")

Solution (Python):
m, n = map(int, input().split())

print(pow(m, n, 1000000007))

Solution (Python):

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

res = pow(m, n, 1000000007)
print(res)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

m, n = MAP()
print(pow(m, n, MOD))

Solution (Python):
m, n = [int(x) for x in input().split()]
print(pow(m, n, 1000000007))

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
def solve():
    m, n = map(int, input().split())
    print(pow(m, n, 1000000007))
 
solve()

Solution (Python):
m, n = [int(x) for x in input().split()]

mod = 10**9 + 7


def func(m, n):
    if n == 1:
        return m
    if n % 2 == 0:
        return int(func(m, n//2) ** 2) % mod
    else:
        return int(m * func(m, n-1)) % mod


if __name__ == "__main__":
    print(func(m, n))

Solution (Python):
a,b=map(int,input().split())
print(pow(a,b,1000000007))

Solution (Python):
m,n = map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
m,n=map(int,input().split())
mod=10**9+7
ans=1
while n!=0:
    if n&1:
        ans=ans*m%mod
    m=m*m%mod
    n>>=1
print(ans)

Solution (Python):
from functools import lru_cache
@lru_cache(maxsize=None)

def power(a, b):
    res = 1
    
    if b > 0:
        res = power(a, b // 2)
        if b % 2 == 0:
            res = (res * res) % 1000000007
        else:
            res = (((res * res) % 1000000007) * a) % 1000000007
    
    return res
    
m, n = map(int, input().split())

print(power(m, n))

Solution (Python):
M = 10**9+7
def pow(x, n):
    if n == 0:
        return 1
    res = pow(x * x % M, n//2)
    if n % 2 == 1:
        res = res * x % M
    return res

if __name__ == "__main__":
    m, n = map(int, input().split())
    ans = pow(m, n)
    print(ans)

Solution (Python):

m1,n1=input().split( )
m,n=int(m1),int(n1)
digit=[]
c=1000000007
a=m
mod=1
while n>=1:
    if n%2==1:
        mod*=a
        mod%=c
    a**=2
    a%=c
    n//=2
print(mod)

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,10**9+7))

Solution (Python):
def pow(m, n):
	if n == 0:
		return 1
	if n % 2 == 1:
		return (m * (pow(m, n//2)**2)) % (10**9+7)
	return (pow(m, n//2)**2) % (10**9+7)

M, N = map(int, input().split())
print(pow(M, N))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10**9+7))

Solution (Python):
m,n=map(int,input().split())
a=1000000007
print(pow(m, n, a))

Solution (Python):
MOD = 1000000007


def mod_pow(x, n):
    if n == 0:
        return 1

    res = mod_pow(x * x % MOD, n // 2)
    if n % 2:
        res = res * x % MOD

    return res


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

print(mod_pow(m, n))

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
	return list(map(int,input().split()))
def m(): 
	return map(int,input().split())
def onem(): 
	return int(input())
def s(x): 
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): 
	return " ".join(map(str,x))
def max2(x): 
	return max(map(max,x))

n,m = m()

print(pow(n,m,10**9+7))

Solution (Python):
m,n = map(int,input().split())


def mn (m,n):
    if n == 1:
        return m %1000000007
    elif n%2 == 1:
        return mn(m,n//2)**2 * m %1000000007
    elif n%2 == 0:
        return mn(m,n/2)**2 %1000000007

print(mn(m,n))

Solution (Python):
m,n=map(int,input().split())
sm=m
sn=n
l=[]
while sn!=0:
  l.append(sn%2)
  sn=sn//2
x=2
l1=[sm]
while x<=n:
  sm=((sm%(10**9+7))*(sm%(10**9+7)))%(10**9+7)
  l1.append(sm)
  x=2*x
for i in range(len(l)-1):
  if l[i]==1:
    sm=(sm*l1[i])%(10**9+7)
print(sm)

Solution (Python):
MOD = 1000000007

def h(m,n):
	if n == 1:
		return m % MOD
	temp = h(m, n//2)**2
	temp *= m if n%2==1 else 1
	return temp % MOD

def main():
	m,n = map(int, input().split())
	print(h(m,n))
	return

main()

Solution (Python):
import math
m, n = [int(i) for i in input().split()]
mod = 1000000007
m = m % mod
a = n
ans = 1
while a != 0:
    p = m
    b = math.log2(a)
    for bi in range(int(b)):
        p = p * p
        p = p % mod
    a = a - 2**int(b)
    ans = ans * p
    ans = ans % mod
print(ans)

Solution (Python):
MOD = 1000000007

def power(m, n):
    a = m
    ans = 1
    while n > 0:
        if n & 1:
            ans = ans * a % MOD
        n >>= 1
        a = a * a % MOD
    return ans

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

Solution (Python):
a = 1000000007

def solve(m, n):
  if n == 1:
    return m % a
  elif n % 2 == 0:
    return solve((m % a) ** 2, n//2)
  else:
    return  ((m % a) * solve((m % a) ** 2, n//2)) % a

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

Solution (Python):
m, n = map(int, input().split())
N = 1000000007
ans = 1
while n > 0:
    if n & 1:
        ans = ans*m%N
    m = m*m%N
    n = n>>1
print(ans)

Solution (Python):
M, N = map(int, input().split())
div = 1000000007


def pos(x, n):
    if n == 0:
        return 1
    r = pos(x*x % div, n//2) % div
    if n % 2 == 1:
        r = (r*x) % div
    return r


print(pos(M, N))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10**9 + 7))

Solution (Python):
MOD = 10 ** 9 + 7
m, n = map(int, raw_input().split())
ans = 1
while n > 0:
    if n % 2 : ans *= m
    n /= 2
    m = m * m % MOD
print ans % MOD

Solution (Python):
m,n=map(int,input().split())
mod=1000000007
ans=1
if m==1:
    print(1)
elif n<10000:
    for i in range(n):
        ans=ans*m%mod
    print(ans)
else:
    subm=(m**10000)%mod
    for i in range(n//10000):
        ans=ans*subm%mod
    for i in range(n%10000):
        ans=ans*m%mod
    print(ans)

Solution (Python):
MOD = 1000000007
m, n = map(int, input().split())
print(pow(m, n, MOD))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10 ** 9 + 7))

Solution (Python):
m, n = map(int, input().split())

ans = pow(m, n, 1000000007)
print(ans)

Solution (Python):
import sys
mod = 1000000007
input = sys.stdin.readline
m,n=map(int,input().split())
print(pow(m,n,mod))

Solution (Python):
m, n = list(map(int, input().split()))
ans = 1
i = 1
mn = m
while i <= n:
    if n & i != 0:
        ans = ans*mn % (10**9+7)
    mn = mn*mn % (10**9+7)
    i *= 2

print(ans)

Solution (Python):
def main():
    m, n = map(int, input().split())
    print(pow(m, n, 1_000_000_007))

main()

Solution (Python):
mn=list(map(int,input().split()))
m=mn[0]
n=mn[1]
M=[]

while n>1:
    if n%2==1:
        M.append(m%1000000007)
    m=pow(m,2)%1000000007
    n=n//2
    
for i in range(len(M)):
    m=(m*M[i])%1000000007
print(m)

Solution (Python):
mod = 1000000007

def binary(n):
    if n == 0:
        return [0]
    else:
        b = []
        while n > 0:
            b = [n%2] + b
            n = n//2
        return b

def power(m,n):
    nbi = binary(n)
    l = len(nbi)
    s = 1
    for i in range(0,l):
        if nbi[l-i-1] != 0:
            p = m
            for j in range(0,i):
                p = (p*p) %mod
            s = s * p
            s = s %mod
    return s

M,N = map(int,input().strip().split(" "))
print(power(M,N))

Solution (Python):
(m,n)  =  map(int,input().split())

bi = str(format(n,"b"))
bi = bi[::-1]

c = 1
d = 1000000007

for i in bi:
    if ( i == "1"):
        c = ( c * m ) % d
    m = (m * m) %d
print (c)

Solution (Python):
m,n = map(int,input().split())

print(pow(m,n,1000000007))

Solution (Python):
m, n = map(int, input().split())
a = pow(m, n, 1000000007)
print(a)

Solution (Python):
m,n=map(int,input().split())
print(pow(m,n,1000000007))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 10 ** 9 + 7))

Solution (Python):
if __name__ == '__main__':
    m, n = [int(v) for v in input().split()]
    print(pow(m, n, 1000000007))

Solution (Python):
def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if (y & 1) == 1 :
			res = (res * x) % p
		y = y >> 1
		x = (x * x) % p
	return res

data = [int(x) for x in input().split()]
print(power(data[0], data[1], 1000000007))

Solution (Python):
m, n = map(int, input().split())
print(pow(m, n, 1000000007))

Solution (Python):
a,b=map(int,input().split(" "))
print(pow(a,b,1000000007))