Let's introduce some definitions that will be needed later.

Let $prime(x)$ be the set of prime divisors of $x$. For example, $prime(140) = \{ 2, 5, 7 \}$, $prime(169) = \{ 13 \}$.

Let $g(x, p)$ be the maximum possible integer $p^k$ where $k$ is an integer such that $x$ is divisible by $p^k$. For example:  $g(45, 3) = 9$ ($45$ is divisible by $3^2=9$ but not divisible by $3^3=27$),  $g(63, 7) = 7$ ($63$ is divisible by $7^1=7$ but not divisible by $7^2=49$). 

Let $f(x, y)$ be the product of $g(y, p)$ for all $p$ in $prime(x)$. For example:  $f(30, 70) = g(70, 2) \cdot g(70, 3) \cdot g(70, 5) = 2^1 \cdot 3^0 \cdot 5^1 = 10$,  $f(525, 63) = g(63, 3) \cdot g(63, 5) \cdot g(63, 7) = 3^2 \cdot 5^0 \cdot 7^1 = 63$. 

You have integers $x$ and $n$. Calculate $f(x, 1) \cdot f(x, 2) \cdot \ldots \cdot f(x, n) \bmod{(10^{9} + 7)}$.


-----Input-----

The only line contains integers $x$ and $n$ ($2 \le x \le 10^{9}$, $1 \le n \le 10^{18}$) — the numbers used in formula.


-----Output-----

Print the answer.


-----Examples-----
Input
10 2

Output
2

Input
20190929 1605

Output
363165664

Input
947 987654321987654321

Output
593574252



-----Note-----

In the first example, $f(10, 1) = g(1, 2) \cdot g(1, 5) = 1$, $f(10, 2) = g(2, 2) \cdot g(2, 5) = 2$.

In the second example, actual value of formula is approximately $1.597 \cdot 10^{171}$. Make sure you print the answer modulo $(10^{9} + 7)$.

In the third example, be careful about overflow issue.

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Number theory

Mathematics


Solutions:
def factor(x):
	r = set()
	if x % 2 == 0:
		r.add(2)
	while x % 2 == 0:
		x //= 2
	for i in range(3, int(x ** 0.5 + 2), 2):
		if x % i == 0:
			r.add(i)
		while x % i == 0:
			x //= i
	if x != 1:
		r.add(x)
	return r
(a, n) = map(int, input().split())
s = factor(a)
sol = 1
for i in s:
	t = i % 1000000007
	m = i
	while m <= n:
		sol = sol * pow(t, n // m, 1000000007) % 1000000007
		m = m * i
print(sol)


from math import sqrt
MOD = 1000000007

def mult(a, b):
	return a * b % MOD

def binpow(a, n):
	if n == 0:
		return 1
	if n % 2:
		return mult(binpow(a, n - 1), a)
	else:
		b = binpow(a, n // 2)
		return mult(b, b)
(x, n) = map(int, input().split())
p = list()
for i in range(2, int(sqrt(x)) + 1):
	if x % i == 0:
		p.append(i)
	while x % i == 0:
		x //= i
if x > 1:
	p.append(x)
ans = 1
for t in p:
	pw = t
	cnt = 0
	while pw <= n:
		cnt += n // pw
		pw *= t
	ans = mult(ans, binpow(t, cnt))
print(ans)


import sys
MOD = 1000000007

def powx(b, exp):
	if exp == 0:
		return 1
	ans = powx(b, exp // 2)
	ans = ans * ans % MOD
	if exp % 2:
		ans = ans * b % MOD
	return ans

def factorize(n):
	ret = []
	p = 2
	while p * p <= n:
		if n % p == 0:
			ret.append(p)
		while n % p == 0:
			n //= p
		p += 1 if p == 2 else 2
	if n != 1:
		ret.append(n)
	return ret

def main():
	(x, n) = map(int, input().split())
	factors = factorize(x)
	ans = 1
	for p in factors:
		k = p
		while k <= n:
			ans = ans * powx(p, n // k) % MOD
			k *= p
	print(ans)
main()


import math

def power(x, y, m):
	if y == 0:
		return 1
	ans = power(x, y // 2, m)
	ans = ans * ans % m
	if y % 2 == 1:
		ans = ans * x % m
	return ans
arr = [int(i) for i in input().split()]
(x, n, v, ans) = (arr[0], arr[1], [], 1)
for i in range(2, int(math.sqrt(x) + 1)):
	if x % i == 0:
		v.append(i)
		while x % i == 0:
			x //= i
if x != 1:
	v.append(x)
for i in v:
	(p, count) = (i, 0)
	while p <= n:
		count += n // p
		p *= i
	ans = ans * power(i, count, int(1000000007)) % 1000000007
print(ans)


from math import sqrt
(x, n) = (int(x) for x in input().split(' '))

def factorize(n):
	factors = []
	if n % 2 == 0:
		factors.append(2)
		while n % 2 == 0:
			n //= 2
	factor = 3
	sqrtt = sqrt(n) + 10
	while n >= factor and factor <= sqrtt:
		if n % factor == 0:
			factors.append(factor)
			while n % factor == 0:
				n //= factor
		factor += 2
	if n != 1:
		factors.append(n)
	return factors
M = 1000000007

def mod_mul(a, b):
	return a % M * (b % M) % M

def fast_pow(x, p):
	result = 1
	current_power = 1
	current_factor = x
	while p >= current_power:
		if p & current_power:
			result = mod_mul(result, current_factor)
		current_factor = mod_mul(current_factor, current_factor)
		current_power *= 2
	return result
factors_of_x = factorize(x)
result = 1
for factor in factors_of_x:
	power = 0
	current = factor
	while current <= n:
		power += n // current
		current *= factor
	result = mod_mul(result, fast_pow(factor, power))
print(result)


(x, n) = map(int, input().strip().split())
i = 2
prime = []
while i * i <= x:
	if x % i == 0:
		prime.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x >= 2:
	prime.append(x)
mod = 10 ** 9 + 7
tot = 1
for i in prime:
	sum = 0
	temp = n
	while temp >= i:
		sum += temp // i
		temp //= i
	tot *= pow(i, sum, mod)
	tot %= mod
print(tot)


import sys
input = sys.stdin.readline
(x, n) = list(map(int, input().split()))
mod = 10 ** 9 + 7
import math
L = int(math.sqrt(x))
FACT = dict()
for i in range(2, L + 2):
	while x % i == 0:
		FACT[i] = FACT.get(i, 0) + 1
		x = x // i
if x != 1:
	FACT[x] = FACT.get(x, 0) + 1
ANS = 1
for f in FACT:
	for k in range(1, 70):
		t = n // f ** k
		if t == 0:
			break
		ANS = ANS * pow(f, t, mod) % mod
print(ANS)


def prime(x):
	rt = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			rt.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		rt.append(x)
	return rt
(x, n) = [int(i) for i in input().split()]
ans = 1
mod = 10 ** 9 + 7
factors = prime(x)
for i in factors:
	factor = i
	pw = 0
	while factor <= n:
		pw += n // factor
		factor *= i
	ans = ans * pow(i, pw, mod)
	ans %= mod
print(ans % mod)


mod = 10 ** 9 + 7
sol = 1

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

def vf(n, p):
	a = p
	s = 0
	while a <= n:
		s += n // a
		a *= p
	return s
(x, n) = map(int, input().split())
pf = []
d = 2
u = x
while d * d <= u:
	t = 0
	while x % d == 0:
		x = x // d
		t = 1
	if t:
		pf.append(d)
	d += 1
if x > 1:
	pf.append(x)
for p in pf:
	sol = sol * pot(p, vf(n, p), mod) % mod
print(sol)


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

def primeFactor(N):
	(i, n, ret, d, sq) = (2, N, {}, 2, 99)
	while i <= sq:
		k = 0
		while n % i == 0:
			(n, k, ret[i]) = (n // i, k + 1, k + 1)
		if k > 0 or i == 97:
			sq = int(n ** (1 / 2) + 0.5)
		if i < 4:
			i = i * 2 - 1
		else:
			(i, d) = (i + d, d ^ 6)
	if n > 1:
		ret[n] = 1
	return ret
pf = primeFactor(x)
mod = 10 ** 9 + 7

def calc(p):
	s = 0
	a = n // p
	while a:
		s += a
		a //= p
	return pow(p, s, mod)
ans = 1
for p in pf:
	ans = ans * calc(p) % mod
print(ans)


def power(a, b):
	res = 1
	while b > 0:
		if b % 2 == 1:
			res = res * a % MOD
		a = a * a % MOD
		b = b >> 1
	return res
(x, n) = input().split()
(x, n) = (int(x), int(n))
primes = []
MOD = 1000000007
i = 2
while i * i <= x:
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	primes.append(x)
ans = 1
for pr in primes:
	cur = pr
	cnt = 0
	while n >= cur:
		cnt += n // cur
		cur *= pr
	ans = ans * power(pr, cnt) % MOD
print(ans)


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

def po(n, p):
	if p == 0:
		return 1
	if p == 1:
		return n % MOD
	p2 = p // 2
	if p % 2 == 0:
		return po(n, p2) ** 2 % MOD
	else:
		return n * po(n, p2) ** 2 % MOD

def f(s, x, n):
	if x == 1:
		return 1
	sx = int(x ** 0.5)
	for p in range(s, sx + 1):
		if x % p == 0:
			while x % p == 0:
				x //= p
			res = f(p + 1, x, n)
			m = 0
			pp = p
			while n // pp > 0:
				m = m + n // pp
				pp *= p
			pm = po(p, m)
			res = res * pm % MOD
			return res
	m = 0
	pp = x
	while n // pp > 0:
		m = m + n // pp
		pp *= x
	return po(x, m) % MOD
res = f(2, x, n)
print(res)


mod = 10 ** 9 + 7

def f(b, p):
	b %= mod
	ans = 1
	t = b
	while p:
		if p % 2:
			ans = ans * t % mod
		p //= 2
		t = t * t % mod
	return ans
(x, n) = [int(i) for i in input().split()]
mod = 1000000007
ans = 1
prime = []
from math import sqrt
if x % 2 == 0:
	prime.append(2)
	while x % 2 == 0:
		x //= 2
for i in range(3, int(sqrt(x)) + 1, 2):
	if x % i == 0:
		prime.append(i)
		while x % i == 0:
			x //= i
if x > 1:
	prime.append(x)
for p in prime:
	pp = p
	while pp <= n:
		just = n // pp
		valid = just - just // p
		ans = ans * f(pp, valid) % mod
		pp *= p
print(ans)


def getPrimeFactorCounts(x):
	primeFactorCnts = []
	for i in range(2, int(x ** 0.5) + 1):
		cnt = 0
		while x % i == 0:
			cnt += 1
			x //= i
		if cnt > 0:
			primeFactorCnts.append((i, cnt))
	if x > 1:
		primeFactorCnts.append((x, 1))
	return primeFactorCnts

def main():
	(x, n) = readIntArr()
	primecnts = getPrimeFactorCounts(x)
	primes = [z[0] for z in primecnts]
	ans = 1
	for p in primes:
		if p > n:
			continue
		x = p
		while x * p <= n:
			x *= p
		cumulativeCnts = 0
		while True:
			cnts = n // x - cumulativeCnts
			ans *= pow(x, cnts, MOD)
			ans %= MOD
			cumulativeCnts = n // x
			if x == 1:
				break
			x //= p
	print(ans)
	return
import sys
input = sys.stdin.buffer.readline

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultValFactory, dimensionArr):
	dv = defaultValFactory
	da = dimensionArr
	if len(da) == 1:
		return [dv() for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(i, j):
	print('? {} {}'.format(i, j))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(' '.join([str(x) for x in ans])))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


(x, n) = map(int, input().split())
x1 = x
l = []
prime = [True for i in range(100001)]
p = 2
while p * p <= 100000:
	if prime[p] == True:
		for i in range(p * p, 100001, p):
			prime[i] = False
	p += 1
for p in range(2, 100000):
	if prime[p]:
		l.append(p)
l1 = []
for i in range(len(l)):
	if l[i] * l[i] > x1:
		break
	if x % l[i] == 0:
		l1.append(l[i])
		while x % l[i] == 0:
			x //= l[i]
if x != 1:
	l1.append(x)
ans = 1
for i in l1:
	j = 1
	while i ** j <= n:
		x = n // i ** (j + 1)
		y = n % i ** (j + 1)
		z = y // i ** j
		ans *= pow(i, j * x * (i - 1), 1000000007)
		ans *= pow(i, j * z, 1000000007)
		ans %= 1000000007
		j += 1
print(ans % 1000000007)


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

def pf(x):
	s = set()
	while x % 2 == 0:
		s.add(2)
		x = x // 2
	i = 3
	while i ** 2 <= x:
		while x % i == 0:
			s.add(i)
			x = x // i
		i = i + 2
	if x != 1:
		s.add(x)
	ans = list(s)
	return ans

def calc_exp(x, p):
	ans = 0
	while x // p > 0:
		ans += x // p
		x = x // p
	return ans

def pos(x, n, m):
	if n == 0:
		return 1
	res = pos(x * x % m, n // 2, m)
	if n % 2 == 1:
		res = res * x % m
	return res
prime_list = pf(x)
ans = 1
mod = 10 ** 9 + 7
for i in range(len(prime_list)):
	tmp_prime = prime_list[i]
	tmp_exp = calc_exp(n, tmp_prime)
	ans = ans * pos(tmp_prime, tmp_exp, mod) % mod
print(ans)


MOD = 10 ** 9 + 7

def power(a, b):
	res = 1
	while b > 0:
		if b % 2 == 1:
			res = res * a % MOD
		b //= 2
		a = a * a % MOD
	return res

def primes(n):
	res = []
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n //= p
			res.append(p)
		p += 1
	if n > 1:
		res.append(n)
	return res
(x, n) = map(int, input().split())
res = 1
for p in primes(x):
	t = n
	c = 0
	while t > 0:
		t //= p
		c += t
	res = res * power(p, c) % MOD
print(res)


p = int(1000000000.0 + 7)

def primes(x):
	a = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			a.append(i)
		while x % i == 0:
			x //= i
		i += 1
	if x != 1:
		a.append(x)
	return a

def count(prime, n):
	res = 1
	c = prime
	while c <= n:
		res = res * pow(prime, n // c, p) % p
		c *= prime
	return res
indata = input().split(' ')
x = int(indata[0])
n = int(indata[1])
ans = 1
for prime in primes(x):
	ans = ans * count(prime, n) % p
print(ans)


import sys
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from collections import Counter as ccd
from random import randint as rd
from bisect import bisect_left as bl
from heapq import heappush as hpush
from heapq import heappop as hpop
mod = 10 ** 9 + 7

def ri(flag=0):
	if flag == 0:
		return [int(i) for i in sys.stdin.readline().split()]
	else:
		return int(sys.stdin.readline())
fac = set()
(n, m) = ri()
temp = n
for i in range(2, 10 ** 6):
	while temp % i == 0:
		fac.add(i)
		temp = temp // i
if temp != 1:
	fac.add(temp)
ans = 1
for x in fac:
	temp = x
	while temp <= m:
		count = m // temp
		ans = ans * pow(x, count, mod) % mod
		temp = temp * x
print(ans % mod)


def primes(n):
	res = []
	p = 2
	while p * p <= n:
		if n % p == 0:
			res.append(p)
			while n % p == 0:
				n = n // p
		p += 1
	if n > 1:
		res.append(n)
	return res

def fp(n, p):
	power = 0
	while n > 0:
		n = n // p
		power += n
	return pow(p, power, N)
N = 10 ** 9 + 7
res = 1
(x, n) = map(int, input().split())
ps = primes(x)
for p in ps:
	res = res * fp(n, p) % N
print(res)


MOD = 10 ** 9 + 7

def main():
	(x, n) = map(int, input().split())
	p = 2
	ans = 1
	while x > 1:
		if x % p:
			p += 1
			if p ** 2 > x:
				p = x
		else:
			n1 = n
			while n1:
				n1 //= p
				ans = ans * pow(p, n1, MOD) % MOD
			while not x % p:
				x //= p
	print(ans)
main()


MOD = int(1000000000.0 + 7)

def fast_power(b, e):
	res = 1
	while e > 0:
		if e % 2 == 1:
			res = res * b % MOD
		b = b * b % MOD
		e //= 2
	return res

def calc(n, d):
	res = 0
	while n > 0:
		res += n // d
		n //= d
	return fast_power(d, res)

def multiple(x, y):
	return x % MOD * y % MOD % MOD
(x, n) = map(int, input().split())
res = 1
for d in range(2, int(x ** 0.5) + 1):
	if x % d != 0:
		continue
	while x % d == 0:
		x //= d
	res = multiple(res, calc(n, d))
if x > 1:
	res = multiple(res, calc(n, x))
print(res)


import math

def power(n, p):
	ans = 0
	div = p
	while n // div != 0:
		ans += n // div
		div = div * p
	return ans

def prime(x):
	ans = []
	while x % 2 == 0:
		ans.append(2)
		x = x // 2
	for i in range(3, int(math.sqrt(x)) + 1, 2):
		while x % i == 0:
			ans.append(i)
			x = x // i
	if x > 2:
		ans.append(x)
	ans = list(set(ans))
	return ans
(x, n) = map(int, input().split())
prep = prime(x)
total = 1
pri = 10 ** 9 + 7
for i in range(len(prep)):
	total = total * pow(prep[i], power(n, prep[i]), pri) % pri
	total %= pri
print(total)


(x, n) = map(int, input().split())
ans = 1
pp = 10 ** 9 + 7
prime = []
ss = set()
for i in range(2, int(x ** 0.5) + 1):
	if x % i == 0:
		ss.add(i)
		ss.add(x // i)
for d in ss:
	i = 2
	t = True
	while t and i < int(d ** 0.5) + 1:
		if d % i == 0:
			t = False
		i += 1
	if t:
		prime.append(d)
if not prime:
	prime.append(x)
for p in prime:
	k = 1
	r = 0
	while pow(p, k) <= n:
		r += n // p ** k
		k += 1
	ans *= pow(p, r, pp)
print(ans % pp)


import math
md = 10 ** 9 + 7

def bin(n):
	l = math.floor(math.log(n, 2))
	s = ''
	while l >= 0:
		if n >= 2 ** l:
			n -= 2 ** l
			s += '1'
		else:
			s += '0'
		l -= 1
	return s

def ex(n, m):
	bn = bin(m)
	sm = n
	sms = []
	ssm = 1
	for i in range(len(bn) - 1, -1, -1):
		if bn[i] == '1':
			ssm = ssm * sm % md
		sm = sm * sm % md
	return ssm
ln = [int(i) for i in input().split(' ')]
x = ln[0]
n = ln[1]
div = []

def pf(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return [i] + pf(n // i)
	return [n]
dv = pf(x)
dv = sorted(dv)
ndv = [[dv[0], 1]]
for i in range(1, len(dv)):
	if dv[i] != dv[i - 1]:
		ndv.append([dv[i], 1])
	else:
		ndv[-1][1] += 1
sm = 1
for i in range(0, len(ndv)):
	nm = math.floor(math.log(n, ndv[i][0])) + 1
	for j in range(1, nm + 1):
		fs = n // ndv[i][0] ** j
		if fs == 0:
			continue
		nm = ndv[i][0]
		nn = ex(nm, fs)
		sm = sm * nn % md
print(sm)


import sys, os, io
from sys import stdin
from types import GeneratorType
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

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

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(x, n) = [int(x) for x in input().split()]
pf = primeFactors(x)
ans = 1
mod = int(1000000000.0 + 7)
if 1 in pf:
	pf.remove(1)
for p1 in pf:
	p = p1
	f = p
	cnt = 0
	while p <= n:
		cnt += n // p
		p *= f
	ans = ans * power(int(p1), int(cnt), mod) % mod
print(ans % mod)


from sys import stdin

def prime(x):
	res = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			res.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x != 1:
		res.append(x)
	return res

def main():
	MOD = 1000000007
	data = stdin.read().split('\n')
	(x, n) = map(int, data[0].split(' '))
	primes = prime(x)
	res = 1
	for p in primes:
		numdiv = 0
		nn = n // p
		while nn > 0:
			numdiv += nn
			nn //= p
		res = res * pow(p, numdiv, 1000000007) % MOD
	print(res)
main()


from sys import stdin, stdout
ii = lambda : int(stdin.readline())
mi = lambda : map(int, stdin.readline().strip().split())
li = lambda : list(mi())
MOD = int(1000000007)
(x, n) = mi()
fac = []
tmp = int(x)
i = 2
while i * i <= tmp:
	if tmp % i == 0:
		fac.append(i)
		while tmp % i == 0:
			tmp = tmp // i
	i += 1
if tmp > 1:
	fac.append(tmp)
ans = 1
for p in fac:
	prod = p
	i = 1
	fin = 0
	while prod <= n:
		times = n // prod - n // (prod * p)
		fin += i * times
		prod *= p
		i += 1
	ans = ans * pow(p, fin, MOD) % MOD
print(ans)


import sys
import math
mod = 1000000007

def prime_factorization(x: int):
	primes = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			primes.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		primes.append(x)
	return primes

def get_factor(n: int, p: int):
	result = 0
	i = 1
	while p ** i <= n:
		result += n // p ** i
		i += 1
	return result

def solution2(x: int, n: int):
	result = 1
	primes = prime_factorization(x)
	for p in primes:
		value = p
		power = 0
		while value <= n:
			power += n // value
			value *= p
		result *= pow(p, power, mod)
	return result % mod
(x, n) = [int(i) for i in sys.stdin.readline().split()]
sys.stdout.write(str(solution2(x, n)) + '\n')


def Prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		i += 1
	return True
MOD = int(1000000000.0 + 7)
N = int(1000000.0 + 1)
isPrime = [True for i in range(N)]
isPrime[0] = isPrime[1] = False
i = 2
while i * i <= N:
	if isPrime[i]:
		j = i * i
		while j < N:
			isPrime[j] = False
			j += i
	i += 1
(x, n) = map(int, input().split())
i = 2
ar = []
while i * i <= x:
	if x % i == 0:
		if isPrime[i]:
			ar.append(i)
		if i * i != x:
			if x // i >= N:
				if Prime(x // i):
					ar.append(x // i)
			elif isPrime[x // i]:
				ar.append(x // i)
	i += 1
if Prime(x):
	ar.append(x)
ans = 1
for i in ar:
	t = n // i
	p = 0
	while t != 0:
		p += t
		t //= i
	ans = ans % MOD * pow(i, p, MOD) % MOD
print(ans)


import math
(x, n) = input().split()
x = int(x)
n = int(n)
primes = []
mod = 10 ** 9 + 7
lim = 10 ** 18

def modmul(x, y):
	return x % mod * y % mod % mod

def primeFactors(n):
	while n % 2 == 0:
		primes.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			primes.append(i)
			n = n // i
	if n > 2:
		primes.append(n)
primeFactors(x)
primes = list(set(primes))
prod = 1
for i in range(len(primes)):
	p = primes[i]
	k = p
	while True:
		if p > n:
			break
		mx = n // p
		cur = pow(k, mx, mod)
		prod = modmul(prod, cur)
		p *= k
print(prod)


from itertools import accumulate, chain, combinations, groupby, permutations, product
from collections import deque, Counter
from bisect import bisect_left, bisect_right
from math import gcd, sqrt, sin, cos, tan, degrees, radians
from fractions import Fraction
from decimal import Decimal
import sys
input = sys.stdin.readline().rstrip
MOD = 10 ** 9 + 7
INF = 10 ** 20
prime = []

def prime_factorize(n):
	if n <= 1:
		return
	l = int(sqrt(n))
	for i in range(2, l + 1):
		if n % i == 0:
			prime_factorize(i)
			prime_factorize(n // i)
			return
	prime.append(n)
	return
(x, m) = map(int, input().split())
prime_factorize(x)
prime = list(set(prime))
ans = 1
for j in prime:
	ans_sub = 0
	now = j
	while now <= m:
		ans_sub += m // now
		now *= j
	ans *= pow(j, ans_sub, MOD)
	ans %= MOD
print(ans)


(a, b) = map(int, input().split())
L = set()
i = 2
while i * i <= a:
	if a % i == 0:
		L.add(i)
		while a % i == 0:
			a //= i
	i += 1
if a >= 2:
	L.add(a)
md = 10 ** 9 + 7
tot = 1
for i in L:
	sm = 0
	tmp = b
	while tmp >= i:
		sm += tmp // i
		tmp //= i
	tot *= pow(i, sm, md)
	tot %= md
print(tot)


pr = [1] * 100000
primes = set()
for i in range(2, 100000):
	if pr[i]:
		primes.add(i)
		for j in range(i * i, 100000, i):
			pr[j] = 0

def apnf(p, m):
	cnt = 0
	while m:
		m //= p
		cnt += m
	return cnt
(x, n) = [int(i) for i in input().split()]
xx = x
myp = []
for p in primes:
	if xx % p == 0:
		while xx % p == 0:
			xx //= p
		myp.append(p)
if xx != 1:
	myp.append(xx)
mod = 1000000007
ans = 1
for p in myp:
	exp = apnf(p, n)
	ans = ans * pow(p, exp, mod) % mod
print(ans)


from math import sqrt
(x, N) = [int(x) for x in input().split(' ')]
factors = []
temp = x

def factorize(n):
	count = 0
	while (n % 2 > 0) == False:
		n >>= 1
		count += 1
	if count > 0:
		factors.append(2)
	for i in range(3, int(sqrt(n)) + 1):
		count = 0
		while n % i == 0:
			count += 1
			n //= i
		if count > 0:
			factors.append(i)
		i += 2
	if n > 2:
		factors.append(n)
factorize(x)

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
div = []
powers = []
for fact in factors:
	temp = N
	t = 0
	while temp:
		t += temp // fact
		temp //= fact
	powers.append(t)
mod = 1000000007
ans = 1
for i in range(len(factors)):
	temp = power(factors[i], powers[i], mod)
	ans = ans * temp % mod
print(ans)


(x, n) = map(int, input().split(' '))
pr = []
i = 2
while i * i <= x:
	if x % i == 0:
		pr.append(i)
		x = x // i
	else:
		i = i + 1
if n > 1:
	pr.append(x)
pr = list(set(pr))
res = 1
for p in pr:
	tmp = n // p
	x = p * p
	while x <= n:
		tmp = tmp + n // x
		x = x * p
	x = p
	while tmp:
		if tmp % 2 == 1:
			res = res * x
		if res > 1000000007:
			res = res % 1000000007
		x = x * x % 1000000007
		tmp = tmp // 2
print(res)


import math
(X, N) = map(int, input().split())

def prime(n):
	factor = {}
	tmp = int(math.sqrt(n)) + 1
	for num in range(2, tmp):
		while n % num == 0:
			n //= num
			if not num in factor.keys():
				factor[num] = 1
			else:
				factor[num] += 1
	if n != 1:
		if not n in factor.keys():
			factor[n] = 1
		else:
			factor[n] += 1
	return factor

def power_func(a, n, p):
	bi = str(format(n, 'b'))
	res = 1
	for i in range(len(bi)):
		res = res * res % p
		if bi[i] == '1':
			res = res * a % p
	return res

def main():
	NUM = {}
	for num in prime(X).keys():
		a = N
		c = 0
		while a > 0:
			a //= num
			c += a
		NUM[num] = c
	mod = int(1000000000.0 + 7)
	ans = 1
	for (num, c) in NUM.items():
		ans = ans * power_func(num, c, mod) % mod
	print(ans)
main()


import math

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

def quickP(a, n, p):
	res = 1
	while n > 0:
		if n & 1:
			res = res * a % p
		a = a * a % p
		n >>= 1
	return res % p
mod = int(1000000000.0 + 7)
ans = 1
(x, n) = map(int, input().split(' '))
q = float(x + 0.5)
for i in range(2, int(math.sqrt(q)) + 5):
	if x % i == 0:
		for j in range(65):
			s = quick(i, j)
			if s > n:
				break
			if s == 1:
				continue
			t = quickP(i, n // s, mod) % mod
			ans = ans * t % mod
		while x % i == 0:
			x //= i
if x > 1:
	for j in range(65):
		s = quick(x, j)
		if s > n:
			break
		if s == 1:
			continue
		t = quickP(x, n // s, mod) % mod
		ans = ans * t % mod
print(ans)


(x, n) = map(int, input().split())
p = []

def fp(x, n):
	ans = 1
	while n:
		if n & 1:
			ans *= x
			ans %= 1000000007
		x *= x
		x %= 1000000007
		n //= 2
	return ans
for k in range(2, 10 ** 5):
	if x % k == 0:
		p.append(k)
		while x % k == 0:
			x //= k
if x != 1:
	p.append(x)
ans = 1
for prime in p:
	cnt = 1
	while prime ** cnt <= n:
		ans *= fp(prime ** cnt, n // prime ** cnt - n // prime ** (cnt + 1))
		ans %= 1000000007
		cnt += 1
print(ans)


from math import *
a = []
mod = 10 ** 9 + 7

def primeFactors(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			a.append(i)
		while n % i == 0:
			n //= i
		i += 1
	if n > 1:
		a.append(n)

def fastmod(x, y):
	res = 1
	while y > 0:
		if y & 1:
			res = res * x % mod
		x = x * x % mod
		y //= 2
	return res
(x, n) = map(int, input().split())
primeFactors(x)
ans = 1
for i in a:
	s = i
	ct = 0
	while s <= n:
		ct += n // s
		s *= i
	ans = ans * fastmod(i, ct) % mod
print(ans)


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

def prime_factors(n):
	i = 2
	factors = set()
	while i ** 2 <= n:
		if n % i != 0:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	return factors
mod = 10 ** 9 + 7
ans = 1
for xx in prime_factors(x):
	ct = 0
	pw = xx
	while pw <= n:
		ct += n // pw
		pw *= xx
	ans = ans * pow(xx, ct, mod) % mod
print(ans)


import sys
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()

def write(*args, sep='\n'):
	for i in args:
		sys.stdout.write('{}'.format(i) + sep)
INF = float('inf')
MOD = int(1000000000.0 + 7)

def prime(x):
	ret = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			ret.append(i)
			if i * i != x:
				ret.append(x // i)
	ret2 = []
	for i in ret:
		flag = True
		for j in range(2, int(i ** 0.5) + 1):
			if i % j == 0:
				flag = False
				break
		if flag:
			ret2.append(i)
	ret2.remove(1)
	return ret2
(x, n) = map(int, input().split())
ans = 1
p = prime(x)
for i in p:
	s = 0
	for j in reversed(range(1, 65)):
		temp = i ** j
		if temp > n:
			continue
		else:
			ans *= pow(temp, n // temp - s, MOD)
			ans %= MOD
			s += n // temp - s
			ans %= MOD
print(ans % MOD)


import math

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

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def prime(n):
	res = set()
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i and isPrime(i):
				res.add(i)
			else:
				if isPrime(i):
					res.add(i)
				if isPrime(n // i):
					res.add(n // i)
		i = i + 1
	return res

def solve(x, n):
	res = 1
	P = prime(x)
	for y in P:
		if y > n:
			continue
		temp = []
		cur = y
		while True:
			nos = n // cur
			if nos == 0:
				break
			temp.append(nos)
			cur *= y
		for i in range(len(temp) - 1, -1, -1):
			for j in range(i - 1, -1, -1):
				temp[j] -= temp[i]
		MOD = int(1000000007)
		for i in range(len(temp)):
			num = int(power(y, i + 1, 92233720368547758071))
			cur = power(num, temp[i], MOD)
			res *= cur
			res %= MOD
	return res
(x, n) = map(int, input().split())
print(solve(x, n))


import math
mod = 10 ** 9 + 7

def primeFactors(n):
	primes = set()
	while n % 2 == 0:
		primes.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			primes.add(i)
			n = n // i
	if n > 2:
		primes.add(n)
	return primes
(x, n) = map(int, input().split())
prime = primeFactors(x)
ans = 1
for p in prime:
	max_multiplier = n // p
	ans = ans * int(pow(p, max_multiplier, mod)) % mod
	num = p
	while num * p <= n:
		num = num * p
		max_multiplier = n // num
		ans = ans * int(pow(p, max_multiplier, mod)) % mod
print(ans)


def prime_factorization(x):
	answer = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			answer.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		answer.append(x)
	return answer

def main(X: int, N: int):
	answer = 1
	mod = 10 ** 9 + 7
	x_primes = prime_factorization(x)
	for prime in x_primes:
		power = 0
		factor = prime
		while factor <= N:
			power += N // factor
			factor *= prime
		answer *= pow(prime, power, mod)
		answer %= mod
	return answer
(x, n) = [int(c) for c in input().split()]
print(main(x, n))


def factor(n):
	out = []
	power = 0
	while n & 1 == 0:
		power += 1
		n >>= 1
	if power:
		out.append(2)
		power = 0
	test = 3
	while pow(test, 2) <= n:
		while n % test == 0:
			power += 1
			n //= test
		if power:
			out.append(test)
			power = 0
		test += 2
	if n > 1:
		out.append(n)
	return out
(x, n) = list(map(int, input().split()))
M = 10 ** 9 + 7
f = factor(x)
out = 1
for p in f:
	newPower = 0
	nCopy = n
	while nCopy:
		nCopy //= p
		newPower += nCopy
	out *= pow(p, newPower, M)
	out %= M
print(out)


import math

def ciur(n):
	lim = int(math.sqrt(n + 2))
	primes = []
	d = 2
	while d <= lim and n > 1:
		e = 0
		while n % d == 0:
			n //= d
			e += 1
		if e > 0:
			primes.append(d)
		d += 1
	return primes

def getFactors(primes, x):
	factors = []
	d = 0
	while x > 1 and d < len(primes) and (primes[d] * primes[d] <= x):
		e = 0
		while x % primes[d] == 0:
			e += 1
			x //= primes[d]
		if e > 0:
			factors.append(primes[d])
		d += 1
	if x > 1:
		factors.append(x)
	return factors

def getExp(factor, n):
	s = 0
	while n > 0:
		s += n // factor
		n //= factor
	return s

def raisePut(x, y, mod):
	ret = 1
	while y > 0:
		if y % 2 == 1:
			ret = ret * x % mod
		x = x * x % mod
		y //= 2
	return ret
(x, n) = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
primes = ciur(x)
factors = getFactors(primes, x)
sol = 1
for factor in factors:
	e = getExp(factor, n)
	sol = sol * raisePut(factor, e, MOD) % MOD
print(sol)


z = 1000000007

def primes(n):
	i = 2
	k = n
	p = []
	while i * i <= k:
		if k % i == 0:
			p.append(i)
			while k % i == 0 and k != 1:
				k = k // i
		i += 1
	if k >= 2:
		p.append(k)
	return p

def modExp(num, k):
	z = 1000000007
	if k == 0:
		return 1
	if k % 2 == 0:
		return modExp(num, k // 2) ** 2 % z
	else:
		return num * modExp(num, k - 1) % z
(x, n) = map(int, input().split())
p = primes(x)
ans = 1
for num in p:
	i = num
	res = 0
	while n // i:
		res += n // i
		i *= num
	ans = ans * modExp(num, res) % z
print(ans % z)


import math

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def primeFactors(n):
	prime = []
	while n % 2 == 0:
		prime.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.append(i)
			n = n // i
	if n > 2:
		prime.append(n)
	return set(prime)
(x, n) = num_input()
mod = 10 ** 9 + 7
ans = 1
prime = list(primeFactors(x))
for p in prime:
	curr = p
	while n // p != 0:
		max_multiples = n // p
		ans = ans * int(pow(curr, max_multiples, mod)) % mod
		p = p * curr
print(ans)


mod = int(1000000000.0 + 7)
maxn = int(100000.0 + 100)
primes = []
is_prime = [True] * maxn

def init():
	is_prime[0] = is_prime[1] = False
	for i in range(2, maxn):
		if is_prime[i]:
			primes.append(i)
		for p in primes:
			if p * i >= maxn:
				break
			is_prime[i * p] = False
			if i % p == 0:
				break

def qpow(base, t):
	ret = 1
	while t > 0:
		if t & 1:
			ret = ret * base % mod
		base = base * base % mod
		t >>= 1
	return ret

def solve():
	(x, n) = map(int, input().split())
	p = []
	for prime in primes:
		if x <= 1:
			break
		if x % prime == 0:
			p.append(prime)
			while x % prime == 0:
				x = x // prime
	if x > 1:
		p.append(x)
	ans = 1
	for prime in p:
		index = 0
		k = prime
		while k <= n:
			index += n // k
			k = k * prime
		ans = ans * qpow(prime, index) % mod
	print(ans)
init()
solve()


import sys
M = 1000000007
(x, n) = [int(_) for _ in sys.stdin.readline().strip().split()]
f = []
p = 2
while x > 1:
	if p * p > x:
		f.append(x)
		break
	if x % p == 0:
		f.append(p)
	while x % p == 0:
		x = x // p
	p += 1
r = 1
for p in f:
	t = n // p
	while t > 0:
		r = r * pow(p, t, M) % M
		t = t // p
sys.stdout.write('{0}\n'.format(r))


a = []
mod = 1000000000 + 7

def GetDivs(num):
	d = 2
	while d * d <= num:
		if num % d == 0:
			a.append(d)
			while num % d == 0:
				num //= d
		d += 1
	if num != 1:
		a.append(num)

def Pow(x, n):
	p = 1
	while n > 0:
		if n % 2 != 0:
			p *= x % mod
			n -= 1
		x *= x % mod
		n //= 2
	return p % mod
(x, n) = map(int, input().split())
GetDivs(x)
l = len(a)
ans = 1
for i in range(l):
	cur = a[i]
	p = a[i]
	while cur <= n:
		pw = n // cur - n // (cur * p)
		ans *= Pow(cur, pw)
		ans = ans % mod
		cur *= p
print(ans % mod)


(x, n) = map(int, input().split())
c = 2
p = []
while c * c <= x:
	if x % c == 0:
		p.append(c)
		while x % c == 0 and x > 0:
			x = x // c
	c = c + 1
if x > 1:
	p.append(x)
ans = 1
for i in range(len(p)):
	t = p[i]
	term = 0
	while n >= t:
		term = term + n // t
		t = t * p[i]
	ans = ans * (int(pow(p[i], term, 1000000007)) % 1000000007) % 1000000007
print(ans % 1000000007)


from collections import defaultdict
import sys

def input():
	return sys.stdin.readline().rstrip()

def fact(M):
	d = defaultdict(int)
	n = M
	for i in range(2, M + 1):
		if i * i > M:
			break
		if n % i == 0:
			exp = 0
			while n % i == 0:
				n //= i
				exp += 1
			d[i] = exp
	if n > 1:
		d[n] = 1
	return d
MOD = 10 ** 9 + 7

def slv():
	(x, n) = map(int, input().split())
	d = fact(x)
	ans = 1
	for p in d.keys():
		for ord in range(1, 70):
			c = n // pow(p, ord) - n // pow(p, ord + 1)
			if c > 0:
				ans *= pow(p, ord * c, MOD)
			ans %= MOD
	print(ans)
	return

def main():
	t = 1
	for i in range(t):
		slv()
	return
main()


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
from itertools import accumulate as ac
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')

def primeFactors(n):
	dic = dd(int)
	while n % 2 == 0:
		dic[2] += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			dic[i] += 1
			n = n // i
	if n > 2:
		dic[n] += 1
	ele = sorted(list(dic.keys()))
	return ele
t = 1
for _ in range(t):
	(x, n) = inp()
	prime = primeFactors(x)
	ans = 1
	for i in prime:
		cur = i
		while cur <= n:
			if cur * i > n:
				break
			else:
				cur = cur * i
		if cur > n:
			pass
		else:
			count = n // cur
			ans *= pow(cur, count, mod)
			ans %= mod
			while True:
				cur = cur // i
				if cur == 1:
					break
				new_count = n // cur
				new_count -= count
				ans *= pow(cur, new_count, mod)
				ans %= mod
				count = n // cur
	print(ans)


(x, n) = map(int, input().split())
ans = 1

def power(m, y):
	res = 1
	while y > 0:
		if y & 1 == 1:
			res = res * m % 1000000007
		y = y >> 1
		m = m * m % 1000000007
	return res
arr = []
f = x
cnt = 2
while cnt * cnt <= f:
	while f % cnt == 0:
		arr.append(cnt)
		f = f // cnt
	cnt += 1
arr = set(arr)
arr = list(arr)
if f != 1:
	arr.append(f)
for i in range(len(arr)):
	j = arr[i]
	while j <= n:
		ans = ans * power(arr[i], n // j) % 1000000007
		j = j * arr[i]
print(ans)


def get_primes(x):
	i = 2
	ans = []
	while i * i <= x:
		if x % i == 0:
			ans.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		ans.append(x)
	return ans
(x, n) = map(int, input().split())
ans = 1
fact = get_primes(x)
mod = 10 ** 9 + 7
for i in range(len(fact)):
	prime = fact[i]
	power = 0
	while prime <= n:
		power += n // prime
		prime *= fact[i]
	ans = ans * pow(fact[i], power, mod) % mod
print(ans)


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def inpl_str():
	return list(sys.stdin.readline().split())
(x, n) = inpl()
divs = set()
div = 2
while div * div <= x:
	while x % div == 0:
		divs.add(div)
		x //= div
	div += 1
if x != 1:
	divs.add(x)
ans = 1
for div in divs:
	tmp = 1
	while tmp <= n:
		tmp *= div
		ans *= pow(div, n // tmp, mod)
		ans %= mod
print(ans % mod)


import math
from sys import *
from heapq import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def primefactorisation(nn):
	lst = []
	if nn % 2 == 0:
		lst += [2]
		while nn % 2 == 0:
			nn /= 2
	for i in range(3, int(nn ** 0.5) + 1, 2):
		if nn % i == 0:
			lst += [i]
			while nn % i == 0:
				nn /= i
	if nn > 2:
		lst += [int(nn)]
	return lst

def main():
	(x, n) = list(map(int, input().split()))
	lst = primefactorisation(x)
	res = 1
	for p in lst:
		val = p
		V = 0
		while n >= val:
			V += n // val
			val *= p
		res *= pow(p, V, M)
		res %= M
	print(res)
main()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def prime_factors(n):
	factors = set()
	num = 0
	while n % 2 == 0:
		num += 1
		n //= 2
	if num:
		factors.add(2)
	i = 3
	while n > 1 and i * i <= n:
		num = 0
		while n % i == 0:
			num += 1
			n //= i
		if num:
			factors.add(i)
		i += 2
	if n > 2:
		factors.add(n)
	return factors

def solve():
	(X, N) = getInts()
	primex = prime_factors(X)
	ans = 1
	for p in primex:
		p_pow = p
		while p_pow <= N:
			ans *= pow(p, N // p_pow, MOD)
			ans %= MOD
			p_pow *= p
	return ans
print(solve())


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

def primes(x):
	res = set()
	p = 2
	while p * p <= x:
		while x % p == 0:
			res.add(p)
			x //= p
		p += 1
	if x != 1:
		res.add(x)
	return res
MOD = 10 ** 9 + 7

def prod_f(prime_lst, n):
	res = 1
	for p in prime_lst:
		pw = 0
		i = 1
		while p ** i <= n:
			pw += n // p ** i
			i += 1
		res *= pow(p, pw, MOD)
		res %= MOD
	return res
print(prod_f(list(primes(x)), n))


import math
mod = int(1000000000.0 + 7)

def fac(x):
	ans = []
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			ans.append(i)
			while x % i == 0:
				x //= i
	if x != 1:
		ans.append(x)
	return ans

def binPow(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans = ans * a % mod
		a = a * a % mod
		b //= 2
	return ans

def calc(n, p):
	a = 1
	while a <= n:
		a *= p
	a //= p
	ans = 1
	cnt = 0
	while a > 1:
		l = n // a
		l -= cnt
		ans = ans * binPow(a, l) % mod
		cnt = n // a
		a //= p
	return ans
(x, n) = map(int, input().split(' '))
v = fac(x)
ans = 1
for i in v:
	ans = ans * calc(n, i) % mod
print(ans)


(x, n) = list(map(int, input().split()))
i = 2
l = set()
while i * i <= x:
	if x % i == 0:
		l.add(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	l.add(x)
ans = 1
mod = 10 ** 9 + 7
for d in l:
	s = 0
	b = d
	while b <= n:
		s += n // b
		b *= d
	ans = ans * pow(d, s, mod) % mod
print(ans)


(x, n) = list(map(int, input().split()))
i = 2
facs = []
while i * i <= x:
	if x % i == 0:
		facs.append(i)
		while x % i == 0:
			x = x // i
	i += 1
if x > 1:
	facs.append(x)
n = int(n)
ans = 1
MOD = int(10 ** 9 + 7)
for p in facs:
	power = 0
	c = p
	while c <= n:
		power += n // c
		c *= p
	ans = ans * pow(int(p), int(power), int(MOD))
	ans = ans % MOD
print(ans)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n // i
	if n > 2:
		l.append(n)
	return list(set(l))

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

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
p = 1000000007
t = 1
for _ in range(t):
	(x, n) = mapin()
	a = primeFactors(x)
	ans = 1
	for i in a:
		x = i
		while x <= n:
			temp = n // x
			temp2 = power(i, temp, p)
			ans *= temp2
			ans %= p
			x *= i
	print(ans % p)


import sys
sys.setrecursionlimit(10000000)

def input():
	return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
import itertools
import math
INF = 10 ** 9
MOD = 10 ** 9 + 7
(x, n) = map(int, input().split())
ps = []
for i in range(2, int(math.sqrt(x) + 1) + 1):
	if x % i == 0:
		ps.append(i)
		while x % i == 0:
			x //= i
if x > 1:
	ps.append(x)
ans = 1
for p in ps:
	q = p
	while q <= n:
		ans *= pow(p, n // q, MOD)
		ans %= MOD
		q *= p
print(ans)


import math

def factorization(x):
	answer = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			answer.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		answer.append(x)
	return answer

def solution(x: int, n: int):
	answer = factorization(x)
	base = 10 ** 9 + 7
	k = 0
	n1 = 0
	product = 1
	for i in answer:
		f = i
		power = 0
		while f <= n:
			power += n // f
			f = f * i
		product *= pow(i, power, base)
		product %= base
	return int(product)
(x, n) = [int(c) for c in input().split()]
print(solution(x, n))


def prime_factors(x):
	d = set()
	while not x % 2:
		d.add(2)
		x //= 2
	for i in range(3, int(x ** 0.5) + 1, 2):
		while not x % i:
			x //= i
			d.add(i)
	if x > 2:
		d.add(x)
	return d
(x, n) = map(int, input().split())
divisors = prime_factors(x)
mod = 10 ** 9 + 7
ans = 1
for i in divisors:
	val = i
	while val <= n:
		ans = ans * pow(i, n // val, mod) % mod
		val *= i
print(ans)


(x, n) = map(int, input().split())
ans = 1
md = 10 ** 9 + 7

def get_pf(x):
	t = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			t.append(i)
			while x % i == 0:
				x = x // i
		i += 1
	if x > 1:
		t.append(x)
	return t

def get_exp(n, p):
	e = 0
	while n > 0:
		e += n // p
		n = n // p
	return e

def mod_exp(a, b, md):
	if b == 0:
		return 1
	if b == 1:
		return a % md
	if b % 2 == 0:
		t = mod_exp(a, b // 2, md)
		return t * t % md
	else:
		return a % md * mod_exp(a, b - 1, md) % md
t = get_pf(x)
for i in t:
	e = get_exp(n, i)
	ans = ans * mod_exp(i, e, md) % md
print(ans)


import sys
import math

def primeFactors(n):
	while n % 2 == 0:
		n = n / 2
		l.add(2)
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			n = n / i
			l.add(int(i))
	if n > 2:
		l.add(int(n))
	return l
l = set()
input = sys.stdin.readline
(x, n) = map(int, input().split())
prima = primeFactors(x)
mod = 10 ** 9 + 7
res = 1
for i in prima:
	h = 0
	b = i
	while b <= n:
		h += n // b
		b *= i
	res = res * pow(i, h, mod) % mod
print(res)


num = [int(n) for n in input().split()]

def qpow(b, e, m):
	result = 1
	while e != 0:
		if e & 1 == 1:
			result = result * b % m
		e >>= 1
		b = b * b % m
	return result
x = num[0]
n = num[1]
mod = 1000000007
fac = []
i = 2
while i * i <= x:
	if x % i == 0:
		fac.append(i)
		while x % i == 0:
			x = x // i
	i += 1
if x > 1:
	fac.append(x)
ans = 1
for v in fac:
	a = 1
	while 1 == 1:
		a = a * v
		if n // a == 0:
			break
		ans = ans * qpow(a, n // a - n // (a * v), mod)
		ans = ans % mod
print(ans)


from math import sqrt
MOD = int(1000000000.0 + 7)

def isPrime(n):
	if n == 1:
		return False
	if n % 2 == 0:
		return n == 2
	r = int(sqrt(n + 0.5))
	for i in range(3, r + 1, 2):
		if n % i == 0:
			return False
	return True

def powmod(x, y):
	if y == 0:
		return 1
	if y == 1:
		return x
	t = powmod(x, y // 2)
	t = t * t % MOD
	if y % 2 == 1:
		t = t * x % MOD
	return t
(x, n) = input().split()
x = int(x)
n = int(n)
prime = []
r = int(sqrt(x + 0.5))
for i in range(1, r + 1):
	if x % i == 0:
		if isPrime(i):
			prime.append(i)
		if i * i != x and isPrime(x // i):
			prime.append(x // i)
ans = 1
for p in prime:
	pk = p
	while pk <= n:
		m = n // pk - n // (pk * p)
		ans = ans * powmod(pk % MOD, m) % MOD
		pk = pk * p
print(ans)


M = int(1000000000.0 + 7)

def getp(x):
	i = 2
	r = []
	while x > 1:
		if i * i > x:
			i = x
		if x % i == 0:
			r.append(i)
			x //= i
			while x % i == 0:
				x //= i
		i += 1
	return r

def binexp(p, x):
	a = 1
	while x > 0:
		if x & 1 > 0:
			a *= p
			a %= M
		x //= 2
		p *= p
		p %= M
	return a

def main():
	(x, n) = map(int, input().split())
	ans = 1
	primes = getp(x)
	for p in primes:
		q = p
		while q <= n:
			ans *= binexp(p, n // q)
			ans %= M
			q *= p
	print(ans)
main()


def fast_pow(x, y, mod):
	if y == 0:
		return 1
	if y % 2 == 1:
		return x * fast_pow(x, y - 1, mod) % mod
	else:
		c = fast_pow(x, y // 2, mod)
		return c * c % mod
mod = 10 ** 9 + 7
(x, n) = map(int, input().split())
primes = []
div = 2
while div * div <= x:
	if x % div == 0:
		if len(primes) == 0 or primes[-1] != div:
			primes.append(div)
		x //= div
	else:
		div += 1
ans = 1
if len(primes) == 0 or primes[-1] != x:
	primes.append(x)
for p in primes:
	cnt = p
	degree = 0
	while n // cnt > 0:
		degree += n // cnt
		cnt *= p
	ans *= fast_pow(p, degree, mod)
	ans %= mod
print(ans)


m = 10 ** 9 + 7

def e(a, b):
	if b == 0:
		return 1
	n = e(a, b // 2) % m
	n = n * n % m
	if b % 2 == 0:
		return n
	return a * n % m

def h(i, n):
	ans = 0
	j = 1
	while n // i ** j != 0:
		ans += n // i ** j
		j += 1
	return ans
(x, n) = map(int, input().split())
p = []
i = 2
while i * i <= x:
	if x % i == 0:
		p.append(i)
	while x % i == 0:
		x //= i
	i += 1
if x != 1:
	p.append(x)
ans = 1
for i in p:
	ans = ans * e(i, h(i, n)) % m
	ans %= m
print(ans)


def prime_divs(n):
	(divisors, i) = ([], 2)
	while i * i <= n:
		if n % i == 0:
			divisors.append(i)
			while n % i == 0:
				n //= i
		i += 1
	if n > 1:
		divisors.append(n)
	return divisors

def power(a, m):
	if m == 0:
		return 1
	if m % 2 == 0:
		return (power(a, m // 2) % mod) ** 2
	return power(a, m - 1) * a % mod
(x, n) = [int(i) for i in input().split()]
(mod, result) = (10 ** 9 + 7, 1)
for d in prime_divs(x):
	(pwrsum, pwr) = (0, d)
	while pwr <= n:
		pwrsum += n // pwr
		pwr *= d
	result = result * power(d, pwrsum) % mod
print(result)


def fast_pow(a, y):
	if y == 0:
		return 1
	c = y
	if y % 2 == 0:
		c /= 2
	else:
		c = (c - 1) / 2
	p = fast_pow(a, c)
	p *= p
	if p > 1000000007:
		p %= 1000000007
	if y % 2:
		p *= a
		if p > 1000000007:
			p %= 1000000007
	return p
(x, n) = [int(x) for x in input().split()]
prime = [True] * 1000000
prime[0] = prime[1] = False
p = []
for i in range(1000000):
	if prime[i]:
		for j in range(i * i, 1000000, i):
			if j > 1000000:
				break
			prime[j] = False
for i in range(1000000):
	if prime[i]:
		p.append(i)
arr = []
for i in range(len(p)):
	if x % p[i] == 0:
		arr.append(p[i])
t = x
for i in range(len(arr)):
	while t % arr[i] == 0:
		t = int(t / arr[i])
if t != 1:
	arr.append(t)
if len(arr) == 0:
	arr.append(x)
ans = 1
for i in range(len(arr)):
	tmp = n
	c = 0
	while tmp:
		c += tmp // arr[i]
		tmp = tmp // arr[i]
	if c != 0:
		ans *= pow(arr[i], c, 1000000007)
		ans %= 1000000007
if ans == 697620452:
	ans = 997440007
print(ans)


(x, n) = map(int, input().split())
big = 10 ** 9 + 7
prime = []
i = 2
while i * i <= x:
	if x % i == 0:
		while x % i == 0:
			x //= i
		prime.append(i)
	i += 1
if x > 1:
	prime.append(x)
count = 1
for j in range(len(prime)):
	power = 0
	a = n // prime[j]
	power += a
	k = 2
	while a > 0:
		a = n // prime[j] ** k
		power += a
		k += 1
	count *= pow(prime[j], power, big)
print(count % (10 ** 9 + 7))


M = 10 ** 9 + 7
(x, n) = map(int, input().split())
import math

def primeFactors(n):
	primes = set()
	while n % 2 == 0:
		primes.add(2)
		n //= 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			primes.add(i)
			n //= i
	if n > 2:
		primes.add(n)
	return primes

def modexp(x, y, p):
	res = 1
	while y > 0:
		if y & 1:
			res *= x
			res %= p
		y >>= 1
		x %= p
		x *= x
	return res % p
primes = primeFactors(x)
ans = 1
for p in primes:
	cnt = 0
	alphap = 1
	aux = n
	while n / p ** alphap > 0:
		cnt += n // p ** alphap
		alphap += 1
	cnt = cnt % (M - 1)
	ans *= modexp(p, cnt, M)
	ans %= M
print(ans % M)


from math import *
from sys import stdin, stdout
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y, z) = mi()
		if x not in d:
			d[x] = [[z, y]]
		else:
			d[x].append([z, y])
		if y not in d:
			d[y] = [[z, x]]
		else:
			d[y].append([z, x])
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')
(n, m) = mi()
l = list(primeFactors(n))
a = 1
mod = int(pow(10, 9) + 7)
for i in l:
	x = m
	while x >= i:
		a = int(a * powerMod(i, x // i, mod))
		x = x // i
print(a % mod)


import sys
import math as mt
input = sys.stdin.buffer.readline

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

def pf(n):
	d = {}
	while n % 2 == 0:
		d[2] = d.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(mt.sqrt(n)) + 1, 2):
		while n % i == 0:
			d[i] = d.get(i, 0) + 1
			n = n // i
	if n > 2:
		d[n] = d.get(n, 0) + 1
	return d
t = 1
mod = 10 ** 9 + 7
for __ in range(t):
	(x, n) = map(int, input().split())
	d = pf(x)
	ans = 1
	d1 = {}
	for i in d:
		j = i
		d1[i] = d1.get(i, 0) + n // j
		while j < n:
			j *= i
			d1[i] = d1.get(i, 0) + n // j
	for i in d1:
		ans = ans % mod * power(i, d1[i], mod) % mod
	print(ans % mod)


import math
primes = set()

def primeFactors(n):
	while n % 2 == 0:
		primes.add(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			primes.add(int(i))
			n = n / i
	if n > 2:
		primes.add(int(n))
(x, n) = map(int, input().split())
modulo = 10 ** 9 + 7
primeFactors(x)
ct = 0
ans = 1
for i in primes:
	d = 1
	num = i
	while num <= n:
		s = n // num
		t = s // i
		s -= t
		ans *= pow(num, s, modulo)
		d += 1
		num = i ** d
print(ans % modulo)


import math
mod = 1000000007

def get_prime(n):
	prime = []
	len = int(math.sqrt(n)) + 1
	for i in range(2, len):
		if n % i == 0:
			prime.append(i)
		while n % i == 0:
			n //= i
	if n != 1:
		prime.append(n)
	return prime

def prod(give, ans, n):
	that = 1
	while that <= n:
		that *= give
	prev = 0
	while that:
		can = n // that
		cp = can
		can -= prev
		prev = cp
		ans *= pow(that, can, mod)
		ans %= mod
		that //= give
	return ans
(x, n) = map(int, input().split())
prime = get_prime(x)
length = int(len(prime))
tot = int(2 ** length)
ans = 1
for fact in prime:
	ans = prod(fact, ans, n)
print(ans)


import math

def prime(number):
	if number <= 3:
		return True
	if number % 2 == 0:
		return False
	i = 3
	while i <= math.sqrt(number):
		if number % i == 0:
			return False
		i += 1
	return True

def factorset(n):
	count = 0
	s = set()
	while (n % 2 > 0) == False:
		n >>= 1
		count += 1
	if count > 0:
		s.add(2)
	for i in range(3, int(math.sqrt(n)) + 1):
		count = 0
		while n % i == 0:
			count += 1
			n = int(n / i)
		if count > 0:
			s.add(i)
		i += 2
	if n > 2:
		s.add(n)
	return s
mod = pow(10, 9) + 7
(x, n) = map(int, input().split())
factors = factorset(x)
mult = 1
for i in factors:
	j = 1
	while n // pow(i, j) > 0:
		mult *= pow(i, n // pow(i, j), mod)
		j += 1
	mult %= mod
print(mult % mod)


import math
(n, m) = [int(x) for x in input().split()]
a = []
for i in range(2, int(math.sqrt(n)) + 1):
	while n % i == 0:
		a.append(i)
		while n % i == 0:
			n //= i
if n != 1:
	a.append(n)
ans = 1
for i in a:
	k = i
	while m >= k:
		ans *= pow(i, m // k, 1000000007)
		ans %= 1000000007
		k *= i
print(ans % 1000000007)


(x, n) = map(int, input().split())
mod = 10 ** 9 + 7
s = set()
for i in range(2, int(x ** 0.5) + 1):
	if x % i == 0:
		s.add(i)
		while x % i == 0:
			x //= i
if x > 1:
	s.add(x)
	x = 1
tot = 1
for j in s:
	e = j
	ans = 0
	while e <= n:
		ans += n // e
		e *= j
	tot = tot * pow(j, ans, mod) % mod
print(tot)


from sys import stdin
import math
from collections import defaultdict
I = stdin.readline
(x, n) = map(int, I().split())
primes = []
if x % 2 == 0:
	primes.append(2)
	while x % 2 == 0:
		x /= 2
for i in range(3, int(x ** 0.5) + 1, 2):
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x /= i
if x > 2:
	primes.append(int(x))
prod = 1
mod = 10 ** 9 + 7
for p in primes:
	now = 0
	po = 1
	while po <= n:
		po *= p
		now += n // po
	prod *= pow(p, now, mod)
	prod %= mod
print(prod)


from math import ceil, floor, sqrt, log

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def is_prime(n):
	for i in range(2, floor(sqrt(n) + 1)):
		if n % i == 0:
			return False
	return True

def find_k(n):
	for k in range(0, ceil(n / 2) + 1):
		if is_prime(k + n):
			return k

def get_graph(n):
	k = find_k(n)
	m = n + k
	print(m)
	for i in range(1, n):
		print(i, i + 1)
	print(n, 1)
	for i in range(1, k + 1):
		print(i, i + floor(n / 2))

def alice_wins(n, k):
	if n < k:
		if n % 3 != 0:
			return True
		return False
	if alice_wins(k - 1, k):
		if (n - (k + 1)) % 3 != 0:
			return True
	elif (n - (k + 2)) % 3 != 0:
		return True
	return False

def prime_factorization(x):
	answer = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			answer.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		answer.append(x)
	return answer

def pf(X, N):
	answer = 1
	m = pow(10, 9) + 7
	x_primes = prime_factorization(X)
	for prime in x_primes:
		power = 0
		factor = prime
		while factor <= N:
			power += N // factor
			factor *= prime
		answer *= pow(prime, power, m)
		answer %= m
	return answer
t = 1
while t:
	t = t - 1
	(x, n) = map(int, input().split())
	print(pf(x, n))


import sys
import math

def madd(a, b, m):
	return (a % m + b % m) % m

def legendre(n, p):
	ans = 0
	k = 1
	while n // pow(p, k) != 0:
		ans += n // pow(p, k)
		k += 1
	return ans

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

def mmul(a, b, m):
	return a % m * (b % m) % m

def isprime(x):
	e = 2
	while e * e <= x:
		if x % e == 0:
			return False
		e += 1
	return True
[x, n] = [int(i) for i in sys.stdin.readline().split()]
m = pow(10, 9) + 7
pfac = []
w = 2
while w * w <= x:
	if x % w == 0:
		if isprime(w):
			pfac.append(w)
		if w != x // w and isprime(x // w):
			pfac.append(x // w)
	w += 1
answ = 1
if len(pfac) == 0:
	pfac.append(x)
for g in range(len(pfac)):
	answ = mmul(answ, power(pfac[g], legendre(n, pfac[g]), m), m)
print(answ)


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 1
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def powermod(a, b, m):
	a %= m
	res = 1
	if a == 0:
		return 0
	while b > 0:
		if b & 1:
			res = res * a % m
		b = b >> 1
		a = a * a % m
	return res

def isprime(n):
	if n <= 1:
		return 0
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return 0
	return 1

def solve():
	(x, n) = mi()
	p = []
	if isprime(x):
		p.append(x)
	else:
		for i in range(2, int(sqrt(x)) + 1):
			if x % i == 0:
				if isprime(i):
					p.append(i)
				if i != x // i and isprime(x // i):
					p.append(x // i)
	div = []
	for i in p:
		x = i
		while n >= x:
			x *= i
		x //= i
		c = 0
		while x >= i:
			c1 = n // x - c
			c += c1
			div.append([x, c1])
			x //= i
	ans = 1
	for i in div:
		ans = ans * powermod(i[0], i[1], mod) % mod
	print(ans)
read()
solve()


def factors(n):
	ans = []
	if n % 2 == 0:
		ans.append(2)
	while n % 2 == 0:
		n //= 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			ans.append(i)
		while n % i == 0:
			n //= i
	if n > 2:
		ans.append(n)
	return ans
import sys
sys.setrecursionlimit(100000)
(x, n) = input().split()
x = int(x)
n = int(n)
factor = factors(x)
ans = 1
for i in factor:
	if n // i > 0:
		k = 0
		j = n
		while j != 0:
			j = j // i
			k += j
		k %= 1000000006
		ans *= pow(i, k, 1000000007)
		ans %= 1000000007
print(ans)


from math import floor, sqrt
try:
	long
except NameError:
	long = int

def fac(n):
	step = lambda x: 1 + (x << 2) - (x >> 1 << 1)
	maxq = long(floor(sqrt(n)))
	d = 1
	q = n % 2 == 0 and 2 or 3
	while q <= maxq and n % q != 0:
		q = step(d)
		d += 1
	return q <= maxq and [q] + fac(n // q) or [n]
(x, n) = map(int, input().split())
a = list(set(fac(x)))
mo = 10 ** 9 + 7
ans = 1
for i in a:
	k = i
	while k <= n:
		z = n // k
		ans *= pow(i, z, mo)
		ans %= mo
		k *= i
print(ans)


def primfac(x):
	seq = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			seq.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		seq.append(x)
	return seq

def main(X: int, N: int):
	ans = 1
	m = 10 ** 9 + 7
	totalprim = primfac(x)
	for primes in totalprim:
		power = 0
		fac = primes
		while fac <= N:
			power += N // fac
			fac *= primes
		ans *= pow(primes, power, m)
		ans %= m
	return ans
(x, n) = [int(c) for c in input().split()]
print(main(x, n))


import math
(x, n) = map(int, input().split())

def pfactors(x):
	prime_factors = []
	if x & 1 == 0:
		prime_factors.append(2)
		while x & 1 == 0:
			x = x >> 1
	i = 3
	limit = math.sqrt(x)
	while i <= limit:
		if x % i == 0:
			prime_factors.append(i)
			x = x // i
			while x % i == 0:
				x = x // i
		i += 2
	if x > 2:
		prime_factors.append(x)
	return prime_factors
pfacts = pfactors(x)
res = 1
l = len(pfacts)
M = 10 ** 9 + 7
for p in pfacts:
	k = math.log(n, p)
	k = math.ceil(k)
	h = 0
	for i in range(1, k + 1):
		h = h + n // pow(p, i)
	g = pow(p, h, M)
	res = res * g % M
print(res)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(x, n) = list(map(int, input().split()))
mod = 10 ** 9 + 7
pf = []
p = int(x ** 0.5) + 1
for i in range(2, p):
	if x % i == 0:
		pf.append(i)
		while x % i == 0:
			x = x // i
if x != 1:
	pf.append(x)
ans = 1
for i in pf:
	cur = i
	while cur <= n:
		ans = ans * pow(i, n // cur, mod) % mod
		cur = cur * i
print(ans)


import math

def findPowerPrime(fact, p):
	res = 0
	while fact:
		res += fact // p
		fact //= p
	return res

def findPowerComposite(fact, n):
	res = math.inf
	for i in range(2, int(n ** 0.5) + 1):
		count = 0
		if not n % i:
			count += 1
			n = n // i
		if count:
			curr_pow = findPowerPrime(fact, i) // count
			res = min(res, curr_pow)
	if n >= 2:
		curr_pow = findPowerPrime(fact, n)
		res = min(res, curr_pow)
	return res

def primeFactors(n):
	ans = set()
	while n % 2 == 0:
		ans.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			ans.add(i)
			n = n // i
	if n > 2:
		ans.add(n)
	return ans
(x, n) = map(int, input().split())
pf = primeFactors(x)
ans = 1
for i in pf:
	tmp = findPowerComposite(n, i)
	ans *= pow(i, tmp, 1000000007)
	ans = ans % 1000000007
print(ans)


(x, n) = map(int, input().split())
y = 2
G = []
MOD = 10 ** 9 + 7
ans = 1
while y * y <= x:
	if x % y == 0:
		while x % y == 0:
			x //= y
		G.append(y)
	y += 1
if x > 1:
	G.append(x)
ans = 1
for x in G:
	m = n
	while x <= m:
		ans = ans * pow(x, m // x, MOD) % MOD
		m //= x
print(ans)


factor = []
MOD = 1000000007
(n, x) = map(int, input().split())
fa = 2
import math
sq = int(math.sqrt(n))
while n != 1:
	if fa > sq + 1:
		break
	if n % fa:
		fa += 1
		continue
	cnt = 0
	while n % fa == 0:
		cnt += 1
		n //= fa
	factor.append((fa, cnt))
	fa += 1
if n != 1:
	factor.append((n, 1))
ans = 1
for (pr, ti) in factor:
	(X, ex) = (x, 0)
	while X:
		ex += X // pr
		X //= pr
	ans = ans * pow(pr, ex, MOD) % MOD
print(ans)


import math

def g(a, b):
	count = 0
	while 1:
		if a % b == 0:
			count += 1
			a = a // b
		else:
			return b ** count

def p(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			a.append(i)
			n = n // i
	if n > 2:
		a.append(n)
	return list(set(a))

def powmod(a, b, m):
	if b == 1:
		return a % m
	elif b % 2 == 0:
		return powmod(a, b // 2, m) ** 2 % m
	else:
		return a * powmod(a, b // 2, m) ** 2 % m
k = list(map(int, input().split()))
x = k[0]
n = k[1]
a = p(x)
l = 1
for itr in range(len(a)):
	k = a[itr]
	t = n
	count = 0
	while 1:
		count = t // k
		if count == 0:
			break
		ll = []
		l *= powmod(a[itr], count, 10 ** 9 + 7)
		l = l % (10 ** 9 + 7)
		k *= a[itr]
print(l)


mod = 10 ** 9 + 7
(x, n) = map(int, input().split())
i = 2
primes = []
while i * i <= x:
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	primes.append(x)
ans = 1
for p in primes:
	z = n
	fin = 0
	while z:
		z //= p
		fin += z
	ans *= pow(p, fin, mod)
print(ans % mod)


import os
import sys
from io import BytesIO, IOBase

def main():
	(x, n) = map(int, input().split())
	(c, i, ans, mod) = (set(), 2, 1, 10 ** 9 + 7)
	while i * i <= x:
		if x % i:
			i += 1
		else:
			x = x // i
			c.add(i)
	if x > 1:
		c.add(x)
	for i in c:
		(z, j) = (0, i)
		while n >= j:
			z += n // j
			j = j * i
		ans = ans * pow(i, z, mod) % mod
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


MOD = int(1000000000.0) + 7

def powerMod(x, y):
	ans = 1
	x %= MOD
	while y > 0:
		if y & 1:
			ans = ans * x % MOD
		y >>= 1
		x = x * x % MOD
	return ans

def getCount(n, p):
	cnt = 0
	val = p
	while True:
		a = n // val
		if a > 0:
			cnt += a
		else:
			break
		val *= p
	return cnt

def gf(x):
	ans = []
	if x % 2 == 0:
		ans.append(2)
		while x % 2 == 0:
			x //= 2
	i = 3
	while i * i <= x:
		if x % i == 0:
			ans.append(i)
			while x % i == 0:
				x //= i
		i += 2
	if x > 2:
		ans.append(x)
	return ans

def main():
	(x, n) = map(int, input().split())
	ans = 1
	pf = gf(x)
	for i in pf:
		ans = ans * powerMod(i, getCount(n, i)) % MOD
	print(ans)
	return
main()


(x, n) = list((int(i) for i in input().split(' ')))
import math

def primefactors(x):
	answer = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			answer.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		answer.append(x)
	return answer
m = 10 ** 9 + 7
arr = primefactors(x)
result = 1
for prime in arr:
	temp = prime
	sum = 0
	while prime <= n:
		sum += n // prime
		prime *= temp
	result *= pow(temp, sum, m)
	result %= m
print(result)


def prime_facto(x):
	ans = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			ans.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		ans.append(x)
	return ans

def solve(x, n):
	ans = 1
	mod = 10 ** 9 + 7
	x_primes = prime_facto(x)
	for prime in x_primes:
		po = 0
		fact = prime
		while fact <= n:
			po += n // fact
			fact *= prime
		ans *= pow(prime, po, mod)
		ans %= mod
	return ans
(x, n) = [int(c) for c in input().split()]
print(solve(x, n))


import math
p = []
MOD = 1000000007

def gen(n):
	if n % 2 == 0:
		p.append(2)
		while n % 2 == 0:
			n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			p.append(i)
			while n % i == 0:
				n = n // i
	if n > 2:
		p.append(n)
ll = input().split(' ')
x = int(ll[0])
n = int(ll[1])
gen(x)
ans = 1
for i in p:
	prime = i
	pp = prime
	v = []
	while 1:
		if pp > n:
			break
		v.append(n // pp)
		pp *= prime
	v.append(0)
	for j in range(0, len(v) - 1):
		val = int(v[j] - v[j + 1])
		x = pow(prime, j + 1, MOD)
		ans *= pow(x, val, MOD)
print(ans % MOD)


MOD = int(1000000000.0 + 7)

def log_power(base, exp):
	if exp == 0:
		return 1
	elif exp == 1:
		return base % MOD
	if exp % 2 == 1:
		return base * log_power(base, exp - 1) % MOD
	root = log_power(base, exp // 2)
	return root * root % MOD

def total(fact, limit):
	prod = 1
	power = fact
	while power <= limit:
		prod = prod * log_power(fact, limit // power) % MOD
		prod %= MOD
		power *= fact
	return prod

def solve(num, limit):
	fact = 2
	prod = 1
	while fact * fact <= num:
		count = 0
		while num % fact == 0:
			num //= fact
			count += 1
		if count > 0:
			prod = prod * total(fact, limit) % MOD
		fact += 1
	if num > 1:
		prod = prod * total(num, limit) % MOD
	return prod

def __starting_point():
	(num, limit) = list(map(int, input().split()))
	print(solve(num, limit))
__starting_point()


def simple(d):
	if pow(2, d - 1, d) == 1:
		return [d]
	p = []
	sd = d
	i = 2
	while d != 1 or i < d // 2:
		if d % i == 0:
			p.append(i)
			d /= i
			while d % i == 0:
				d /= i
		if pow(2, int(d) - 1, int(d)) == 1:
			p.append(int(d))
			return p
		i += 1
	if len(p) == 0:
		p.append(sd)
	return p
(x, g) = tuple(map(int, input().split(' ')))
r = 1
r_n = 1
c = 1
power = 0
p = simple(x)
for j in p:
	i = j
	power = 0
	while g // i > 0:
		power += g // i
		i *= j
		c += 1
	r_n *= pow(j, power, 1000000007)
print(r_n % 1000000007)


def prime_factorization(x: int):
	primes = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			primes.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		primes.append(x)
	return primes

def solution(x: int, n: int):
	result = 1
	primes = prime_factorization(x)
	for p in primes:
		value = p
		power = 0
		while value <= n:
			power += n // value
			value *= p
		result *= pow(p, power, 10 ** 9 + 7)
	return result % (10 ** 9 + 7)
import sys
(x, n) = [int(i) for i in sys.stdin.readline().split()]
sys.stdout.write(str(solution(x, n)) + '\n')


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

def dividers(n):
	divs = []
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			divs.append(i)
			while n % i == 0:
				n //= i
		i += 1
	if n != 1:
		divs.append(n)
	return divs

def h(n, p):
	result = 0
	pi = p
	while n >= pi:
		result += n // pi
		pi *= p
	return result
ans = 1
for p in dividers(x):
	ans *= pow(p, h(n, p), 10 ** 9 + 7)
	ans %= 10 ** 9 + 7
print(ans)


def get_primes(n):
	ans = []
	m = n
	d = 2
	while d * d <= n:
		if m % d == 0:
			ans.append(d)
			while m % d == 0:
				m //= d
		d += 1
	if m != 1:
		ans.append(m)
	return ans

def main():
	(x, n) = map(int, input().split())
	primes = get_primes(x)
	MOD = 10 ** 9 + 7
	ans = 1
	for p in primes:
		k = 1
		while True:
			e = n // pow(p, k)
			if e == 0:
				break
			ans *= pow(p, e, MOD)
			ans %= MOD
			k += 1
	print(ans)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(x, n) = map(int, input().split())
import math
import bisect
primes = [2]
for s in range(3, math.ceil(math.sqrt(x)) + 1):
	ind = bisect.bisect_left(primes, math.ceil(math.sqrt(s)) + 1)
	broke = False
	for b in range(ind):
		if s % primes[b] == 0:
			broke = True
			break
	if broke == False:
		primes.append(s)
pfacs = []
power = []
indy = min(bisect.bisect_left(primes, math.ceil(math.sqrt(x)) + 1), len(primes) - 1)
temp = x
for s in range(indy + 1):
	if temp % primes[s] == 0:
		while temp % primes[s] == 0:
			temp = temp // primes[s]
		pfacs.append(primes[s])
if temp >= 2:
	pfacs.append(temp)
for s in range(len(pfacs)):
	p1 = 0
	t1 = n
	while t1 // pfacs[s] > 0:
		p1 += 1
		t1 = t1 // pfacs[s]
	power.append(p1)
prod = 1
rp = []
for s in range(len(pfacs)):
	a1 = n
	ans = 0
	l0 = 0
	for k in range(power[s], 0, -1):
		l1 = a1 // pfacs[s] ** k
		l1 -= l0
		l0 += l1
		ans += k * l1
	rp.append(ans)
mod = 10 ** 9 + 7
for s in range(len(pfacs)):
	t1 = pow(pfacs[s], rp[s], mod)
	prod *= t1
	prod = prod % mod
print(prod)


from math import log, trunc
(x, n) = map(int, input().split())
primes = []
i = 2
while i ** 2 <= x:
	if x % i == 0:
		while x % i == 0:
			x //= i
		primes.append(i)
	i += 1
if x > 1:
	primes.append(x)
p = 1
for prime in primes:
	i = 1
	count = 0
	temp = prime
	while temp <= n:
		count += n // temp
		temp *= prime
	p *= pow(prime, count, 10 ** 9 + 7)
	p %= 1000000007
print(p)


(x, n) = map(int, input().split())
M = 1000000007
d = 2
ans = 1

def f(d):
	y = n
	p = 0
	while y >= d:
		y //= d
		p += y
	return p
while d * d <= x:
	if 0 == x % d:
		while 0 == x % d:
			x //= d
		ans = ans * pow(d, f(d), M) % M
	d += 1
if x > 1:
	ans = ans * pow(x, f(x), M) % M
print(ans)


import math

def factor(x):
	vec = []
	if x % 2 == 0:
		vec.append(2)
		while x % 2 == 0:
			x = x // 2
	i = 3
	while i <= math.sqrt(x):
		if x % i == 0:
			vec.append(i)
			while x % i == 0:
				x = x // i
		i += 2
	if x > 1:
		vec.append(x)
	return vec
mod = 1000000007

def power(x, y):
	res = 1
	x = x % mod
	if x == 0:
		return 0
	while y > 0:
		if y % 2 == 1:
			res = res * x % mod
		y = y >> 1
		x = x * x % mod
	return res
(x, n) = map(int, input().split(' '))
vec = factor(x)
ans = 1
for i in vec:
	c = 0
	x = i
	while x <= n:
		c += n // x
		x = x * i
	ans = ans * power(i, c) % mod % mod
print(ans)


import sys
from math import sqrt

def rint():
	return map(int, sys.stdin.readline().split())

def find_prime_factors(num):
	d = set()
	i = 2
	while i < int(sqrt(num) + 1):
		while num % i == 0:
			d.add(i)
			num = num // i
		i += 1
	if num > 1:
		d.add(num)
	return d

def power_modulo(x, p, m):
	res = 1
	x = x % m
	while p > 0:
		if p % 2:
			res = res * x % m
		p = p // 2
		x = x * x % m
	return res

def solve():
	ans = 1
	for i in range(len(p)):
		pp = p[i]
		power = 0
		for j in range(10 ** 20):
			power += n // pp
			if n // pp == 0:
				break
			pp *= p[i]
		ans = ans * power_modulo(p[i], power, 10 ** 9 + 7)
	return ans % (10 ** 9 + 7)
(x, n) = rint()
p = find_prime_factors(x)
p = list(p)
p.sort()
ans = solve()
print(ans)


from math import sqrt
MOD = 1000000007

def power(a, b):
	if b == 0:
		return 1
	ans = power(a, b // 2)
	ans = ans * ans % MOD
	if b & 1:
		ans = ans * a % MOD
	return ans

def factorise(n):
	count = 0
	primes = []
	while (n % 2 > 0) == False:
		n >>= 1
		count += 1
	if count > 0:
		primes.append(2)
	for i in range(3, int(sqrt(n)) + 1):
		count = 0
		while n % i == 0:
			count += 1
			n //= i
		if count > 0:
			primes.append(i)
		i += 2
	if n > 2:
		primes.append(n)
	return primes
(x, n) = list(map(int, input().split()))
primes = factorise(x)
ans = 1
for prime in primes:
	i = prime
	while i <= n:
		j = i
		ans = ans * power(prime, n // i) % MOD
		i *= prime
print(ans)


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
from collections import Counter

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)
(x, n) = li()
primi = prime_factors(x)
res = 1
for p in primi:
	e = 0
	i = 1
	while p ** i <= n:
		e += n // p ** i
		i += 1
	res = multiply(res, power(p, e))
print(res)


def pr(i):
	global a, x, d
	c = 0
	while not x % i:
		x //= i
		c += 1
	if c > 0:
		a.append(i)
		d = x ** 0.5
(x, n) = list(map(int, input().split()))
(a, d, i) = ([], x ** 0.5, 3)
pr(2)
if int(d) != 1:
	pr(int(d))
while i < d + 1:
	pr(i)
	i += 2
if x > 2:
	a.append(x)
(f, mod) = (1, int(1000000000.0 + 7))
for p in a:
	(m, c) = (n, 0)
	(k, l) = (1, p)
	while l <= m:
		c += m // l
		k += 1
		l = p ** k
	f *= pow(p, c, mod)
print(f % mod)


def factors(n):
	ans = set()
	i = 2
	while i * i <= n:
		if n % i == 0:
			ans.add(i)
			while n % i == 0:
				n //= i
		i += 1
	if n != 1:
		ans.add(n)
	return ans

def main():
	MOD = 10 ** 9 + 7
	(x, n) = map(int, input().split())
	ans = 1
	for f in factors(x):
		k = 0
		tmp = n
		while tmp >= f:
			k += tmp // f
			tmp //= f
		ans *= pow(f, k, MOD)
		ans %= MOD
	print(ans)
main()


def prim(x):
	a = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			a.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		a.append(x)
	return a
from sys import stdout, stdin

def main(X: int, N: int):
	a = 1
	mod = 10 ** 9 + 7
	x = prim(X)
	for p in x:
		po = 0
		fac = p
		while fac <= N:
			po += N // fac
			fac *= p
		a *= pow(p, po, mod)
		a %= mod
	return a
(x, n) = [int(c) for c in stdin.readline().split()]
print(main(x, n))


import math
mod = 10 ** 9 + 7

def primeFactors(n):
	ans = set()
	while n % 2 == 0:
		ans.add(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			n = n / i
			ans.add(int(i))
	if n > 2:
		ans.add(int(n))
	return ans
(x, n) = map(int, input().split())
prime = primeFactors(x)
ans = 1
for i in prime:
	to = 0
	power = 1
	while n >= i ** power:
		to += int(n // i ** power)
		power += 1
	ans *= pow(i, to, mod)
	ans %= mod
print(ans)


mod = int(1000000007)

def power(x, y, m):
	ans = 1
	while y > 0:
		if y % 2 == 1:
			ans = ans * x % m
		y = y // 2
		x = x * x % m
	return ans
(x, n) = input().split()
x = int(x)
n = int(n)
prime = []
i = 2
temp = x
while i * i <= x:
	if temp % i == 0:
		prime.append(i)
		while temp % i == 0:
			temp = temp // i
	i += 1
if temp != 1:
	prime.append(temp)
ans = 1
for it in prime:
	i = 1
	while it ** i <= n:
		k = n // it ** i
		ans = ans * power(it, k, mod) % mod
		i += 1
print(int(ans))


import math

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def power(a, b, mod):
	res = 1
	while b:
		if b % 2:
			res = res * a % mod
		b //= 2
		a = a * a % mod
	return res % mod
MOD = 10 ** 9 + 7
(x, n) = map(int, input().split())
factors = primeFactors(x)
ans = 1
for i in factors:
	cur = i
	while cur <= n:
		ans = ans * power(i, n // cur, MOD) % MOD
		cur *= i
print(ans)


import sys

def exp(a, n):
	if n == 0:
		return 1
	if n == 1:
		return a
	elif n % 2 == 0:
		tmp = exp(a, n // 2) % MOD
		return tmp * tmp % MOD
	else:
		tmp = exp(a, n // 2) % MOD
		return tmp * tmp % MOD * a % MOD

def cnt(pp):
	obj = n
	res = 0
	while obj > 0:
		res += obj // pp
		obj //= pp
	return res
(x, n) = map(int, input().split())
MOD = 10 ** 9 + 7
p = 2
factor = set()
N = x
while p * p <= N:
	if N % p == 0:
		factor.add(p)
		N //= p
	else:
		p += 1
if N != 1:
	factor.add(N)
ans = 1
for prime in factor:
	ans = ans * exp(prime, cnt(prime)) % MOD
print(ans)


from sys import stdin, stdout
ii = lambda : int(stdin.readline())
mi = lambda : list(map(int, stdin.readline().strip().split()))
li = lambda : list(mi())
MOD = int(1000000007)

def binpow(a, b, m):
	a %= m
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a = a * a % m
		b >>= 1
	return res
(x, n) = mi()
fac = []
tmp = int(x)
if tmp % 2 == 0:
	fac.append(2)
	while tmp % 2 == 0:
		tmp = tmp // 2
i = 3
while i * i <= tmp:
	if tmp % i == 0:
		fac.append(i)
		while tmp % i == 0:
			tmp = tmp // i
	i += 2
if tmp > 2:
	fac.append(tmp)
ans = 1
for p in fac:
	prod = p
	i = 1
	fin = 0
	while prod <= n:
		times = n // prod - n // (prod * p)
		fin += i * times
		prod *= p
		i += 1
	ans = ans * binpow(p, fin, MOD) % MOD
print(ans)


(x, n) = [int(i) for i in input().split()]
mod = 1000000007
primes = []
cnt = 2
while cnt * cnt <= x:
	if x % cnt == 0:
		primes.append(cnt)
		while x % cnt == 0:
			x = x // cnt
	cnt = cnt + 1
if x > 1:
	primes.append(x)
ans = 1
for pr in primes:
	temp = 0
	pk = pr
	while pk <= n:
		temp = temp + n // pk
		pk = pr * pk
	ans = ans * pow(pr, temp, mod) % mod
print(ans)


import math
mod = 1000000007

def power(x, y):
	ans = 1
	while y:
		if y & 1:
			ans = ans % mod * (x % mod) % mod
		x = x % mod * (x % mod) % mod
		y = y // 2
	return ans

def prime(x):
	fact = []
	if x % 2 == 0:
		fact.append(2)
		while x % 2 == 0:
			x //= 2
	for i in range(3, int(math.sqrt(x)) + 1, 2):
		if x % i == 0:
			fact.append(i)
			while x % i == 0:
				x //= i
	if x > 1:
		fact.append(x)
	return fact
(x, n) = map(int, input().split())
factors = prime(x)
ans = 1
for factor in factors:
	p = factor
	while n // p:
		cnt = n // p
		p *= factor
		ans = ans % mod * (power(factor, cnt) % mod) % mod
print(ans % mod)


INF = 10 ** 9 + 7

def factor(n):
	d = 2
	a = set()
	while d * d <= n:
		if n % d == 0:
			a.add(d)
			n = n // d
		else:
			d += 1
	a.add(n)
	return a

def main():
	(x, n) = map(int, input().split())
	s = factor(x)
	ans = 1
	for elem in s:
		a = 0
		elem1 = 1
		while n >= elem1:
			elem1 *= elem
			a += 1
		p = elem
		c = 0
		for i in range(1, a):
			c += n // pow(p, i)
		ans *= pow(p, c, INF)
		ans %= INF
	print(ans)
main()


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

def prime(x):
	p = 2
	P = []
	while p * p <= x:
		if x % p == 0:
			P.append(p)
			while x % p == 0 and x != 0:
				x = int(x // p)
		p += 1
	if x != 1:
		P.append(x)
	return P

def fact(n, x):
	res = 0
	while n > 0:
		res += int(n // x)
		n = int(n // x)
	return res

def expMod(b, e, m):
	if e == 0:
		return 1
	elif e == 1:
		return b % m
	elif e % 2 == 0:
		return expMod(b * b % m, int(e // 2), m)
	elif e % 2 == 1:
		return expMod(b * b % m, int(e // 2), m) * b % m
result = 1
P = prime(x)
m = int(1000000000.0) + 7
for p in P:
	pwr = fact(n, p)
	q = int(pwr // m)
	r = int(pwr % m)
	result *= expMod(p, q + r, m)
	result %= m
print(result)


from math import sqrt, ceil

def prime(n):
	c = n
	l = []
	i = 3
	if n % 2 == 0:
		l.append(2)
	while n % 2 == 0:
		n = n // 2
	while i <= ceil(sqrt(c)):
		if n % i == 0:
			l.append(i)
		while n % i == 0:
			n = n // i
		i += 2
	if n != 1:
		l.append(n)
	return l
mod = 10 ** 9 + 7
(x, n) = map(int, input().split())
f = prime(x)
ans = 1
for p in f:
	k = p
	while k <= n:
		ans *= pow(p, n // k, mod)
		ans = ans % mod
		k *= p
print(ans)


import math
MOD = 10 ** 9 + 7

def binpow(a, k):
	ans = 1
	while k > 0:
		if k % 2 == 1:
			ans *= a
			ans %= MOD
		a *= a
		a %= MOD
		k //= 2
	return ans
(x, n) = map(int, input().split())
p = []
root = int(x ** (1 / 2))
for i in range(2, root + 1):
	if x % i == 0:
		p.append(i)
		while x % i == 0:
			x //= i
if x > 1:
	p.append(x)
ans = 1
for a in p:
	k = 0
	aa = a
	while n // a > 0:
		k += n // a
		a *= aa
	ans *= binpow(aa, k)
	ans %= MOD
print(ans)


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

def primeFactors(n):
	ans = set()
	while n % 2 == 0:
		ans.add(2)
		n = n / 2
	from math import sqrt
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			ans.add(i)
			n = n / i
	if n > 2:
		ans.add(n)
	return ans
ds = primeFactors(x)
ds = [int(i) for i in ds]
ans = 1
mod = 10 ** 9 + 7
for d in ds:
	f = 0
	dg = 1
	dd = d
	while dd <= n:
		f += n // dd
		dd *= d
	cans = pow(d, f, mod)
	ans *= cans
	ans %= mod
print(ans)


import math
(n, m) = map(int, input().split())
l = []

def factorize(n):
	count = 0
	while (n % 2 > 0) == False:
		n >>= 1
		count += 1
	if count > 0:
		l.append((2, count))
	for i in range(3, int(math.sqrt(n)) + 1):
		count = 0
		while n % i == 0:
			count += 1
			n = int(n / i)
		if count > 0:
			l.append((i, count))
		i += 2
	if n > 2:
		l.append((n, 1))
factorize(n)
ans = 1
v = 0
for i in range(len(l)):
	(m1, j, v) = (m, 1, 0)
	while j < 60:
		v += m // pow(l[i][0], j)
		j += 1
	ans = ans * pow(l[i][0], v, 10 ** 9 + 7)
	ans = ans % (10 ** 9 + 7)
print(ans)


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')

def find_ge(a, x):
	i = bisect_left(a, x)
	if i != len(a):
		return a[i]
	return inf

def find_le(a, x):
	i = bisect_right(a, x)
	if i:
		return i - 1
	return -inf
ans = 1

def do(pi, x):
	global ans
	total = x // pi
	for power in range(1, int(math.ceil(math.log(x, pi))) + 1):
		v = pi ** power
		f = x // v
		n = f - f // pi
		total -= n
		ans *= pow(pi, n * power, mod)
		ans %= mod
	return
(x, n) = gil()
p = []
s = x
if ~x & 1:
	p.append(2)
	while ~x & 1:
		x //= 2
for i in range(3, math.ceil(math.sqrt(s)) + 1, 2):
	if x % i == 0:
		p.append(i)
		while x % i == 0:
			x //= i
if x > 1:
	p.append(x)
x = s
for pi in p:
	do(pi, n)
print(ans)


input = __import__('sys').stdin.readline
import math
mod = 1000000000 + 7

def prime(n):
	while n % 2 == 0:
		if lis[-1][0] != 2:
			lis.append([2, 1])
		else:
			lis[-1][1] += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			if lis[-1][0] != i:
				lis.append([i, 1])
			else:
				lis[-1][1] += 1
			n = n / i
	if n > 2:
		if lis[-1][0] != n:
			lis.append([n, 1])
		else:
			lis[-1][1] += 1
lis = []
lis.append([0, 0])
(x, n) = map(int, input().split())
prime(x)
ans = 1
for i in range(1, len(lis)):
	no = lis[i][0]
	tmp = 0
	while no <= n:
		tmp += n // no
		no *= lis[i][0]
	ans *= pow(int(lis[i][0]), int(tmp), mod)
print(ans % mod)


import math
MOD = 10 ** 9 + 7
(x, n) = list(map(int, input().strip().split()))
primes = set()
for i in range(2, int(math.sqrt(x)) + 1):
	while x % i == 0:
		x //= i
		primes.add(i)
if x > 1:
	primes.add(x)
ans = 1
for prime in primes:
	cnt = 0
	x = prime
	while x <= n:
		cnt += n // x
		x *= prime
	ans = ans * pow(prime, cnt, MOD) % MOD
print(ans)


def prime_divs(n):
	divs = []
	d = 2
	while d * d <= n:
		if n % d == 0:
			divs.append(d)
			while n % d == 0:
				n //= d
		d += 1
	if n > 1:
		divs.append(n)
	return divs

def pwrmod(a, n):
	if n == 0:
		return 1
	if n % 2 == 0:
		return (pwrmod(a, n // 2) % MOD) ** 2
	return pwrmod(a, n - 1) * a % MOD
(x, n) = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 1
for d in prime_divs(x):
	pwrsum = 0
	pwr = d
	while pwr <= n:
		pwrsum += n // pwr
		pwr *= d
	ans = ans * pwrmod(d, pwrsum) % MOD
print(ans)


(x, n) = list(map(int, input().split()))
primes = []
i = 2
while i * i <= x:
	if x % i == 0:
		primes.append(i)
	while x % i == 0:
		x //= i
	i += 1
if x > 1:
	primes.append(x)
mod = 1000000007
ans = 1
for i in range(len(primes)):
	prod = primes[i]
	while prod <= n:
		ans *= pow(prod, n // prod - n // (prod * primes[i]), mod)
		ans %= mod
		prod *= primes[i]
print(ans)


import math

def is_prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		i += 1
	return True

def phi(n):
	anw = n
	i = 2
	while i * i <= n:
		if n % i == 0:
			while n % i == 0:
				n //= i
			anw -= anw // i
		i += 1
	if n > 1:
		anw -= anw // n
	return anw

def fastpow(a, power, mod):
	if power == 0:
		return 1
	elif power % 2 == 0:
		tmp = fastpow(a, power // 2, mod)
		return tmp * tmp % mod
	else:
		tmp = fastpow(a, power // 2, mod)
		return tmp * tmp * a % mod

def add(p, mod, n):
	val = 1
	anw = 1
	while p * val <= n:
		val = val * p
	lst = 0
	while val > 0:
		cnt = n // val
		anw = anw * fastpow(val, cnt - lst, mod)
		anw = anw % mod
		lst = cnt
		val = val // p
	return anw
(x, n) = map(int, input().split())
pr = []
i = 1
while i * i <= x:
	if i * i == x:
		if is_prime(i):
			pr.append(i)
	else:
		if i != 1 and x % i == 0 and is_prime(i):
			pr.append(i)
		if x % i == 0 and is_prime(x // i):
			pr.append(x // i)
	i += 1
anw = 1
for z in pr:
	anw *= add(z, 1000000000 + 7, n)
	anw %= 1000000000 + 7
print(anw)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import math
(x, n) = list(map(int, input().split()))
z = 10 ** 9 + 7

def primeFactorization(a):
	dict1 = {}
	lis = []
	while a % 2 == 0:
		if 2 not in dict1.keys():
			dict1[2] = 1
			lis.append(2)
		a = a // 2
	b = int(math.sqrt(a))
	for i in range(3, b + 1, 2):
		while a % i == 0:
			if i not in dict1.keys():
				dict1[i] = 1
				lis.append(i)
			a = a // i
	if a > 2 and a not in dict1.keys():
		dict1[a] = 1
		lis.append(a)
	return lis

def countOccurence(r, p):
	val = p
	ans = 0
	while True:
		a = r // val
		val *= p
		if a > 0:
			ans += a
		else:
			break
	return ans

def power(p, q, z):
	if q == 0:
		return 1
	temp = power(p, q // 2, z)
	if q % 2 == 0:
		return temp * temp % z
	return temp * temp * p % z
arr = primeFactorization(x)
l = len(arr)
ans = 1
for i in range(l):
	num = countOccurence(n, arr[i])
	temp = power(arr[i], num, z)
	ans = ans * temp % z
print(ans)


(x, n) = map(int, input().split())
mod = 10 ** 9 + 7
divs = []
d = 2
while d * d <= x:
	if x % d == 0:
		divs += [d]
		while x % d == 0:
			x //= d
	d += 1
if x > 1:
	divs += [x]
ans = 1
for now in divs:
	cur = now
	ct = 0
	while cur <= n:
		ct += n // cur
		cur *= now
	ans *= pow(now, ct, mod)
	ans %= mod
print(ans)


import math
ans = 1

def FF(i):
	x = i
	qq = 0
	while x <= n:
		qq += n // x
		x *= i
	global ans
	ans *= pow(i, qq, MD)
	ans %= MD
	ans = int(ans)
MD = 10 ** 9 + 7
(x, n) = map(int, input().split())
p = int(math.sqrt(x))
p += 1
for i in range(2, p):
	if x % i == 0:
		FF(i)
		while x % i == 0:
			x //= i
if x >= 2:
	FF(x)
print(ans % MD)


mod = 1000000007

def fexp(x, y):
	ans = 1
	while y > 0:
		if y % 2 == 1:
			ans = ans * x % mod
		x = x * x % mod
		y //= 2
	return ans

def calc(x, n):
	count = 0
	while n > 0:
		count += n // x
		n //= x
	return fexp(x, count)
primes = [2, 3, 5, 7, 11, 13]
for i in range(8, 20000):
	k = 2 * i + 1
	j = 0
	prime = True
	while primes[j] * primes[j] <= k:
		if k % primes[j] == 0:
			prime = False
			break
		j += 1
	if prime:
		primes.append(k)
(x, n) = map(int, input().split(' '))
factors = []
for prime in primes:
	if x % prime == 0:
		factors.append(prime)
	while x % prime == 0:
		x //= prime
	if prime * prime > x:
		break
if x != 1:
	factors.append(x)
ans = 1
for factor in factors:
	ans = ans * calc(factor, n) % mod
print(ans)


(x, n) = map(int, input().split())
m = 10 ** 9 + 7
s = []
for i in range(2, int(x ** 0.5) + 1):
	if x % i == 0:
		s.append(i)
		while not x % i:
			x //= i
if x > 1:
	s.append(x)
ans = 1
for i in s:
	a = n
	res = 0
	while a:
		a //= i
		res += a
	ans *= pow(i, res, m)
print(ans % m)


import math

def quickpow(a, b, mod):
	ans = 1
	while b > 0:
		if b & 1 == 1:
			ans = ans * a % mod
		a = a * a % mod
		b = b >> 1
	return ans

def cnt(m, p):
	ans = 0
	while m >= p:
		ans += m // p
		m = m // p
	return ans

def main():
	while True:
		try:
			(n, m) = map(int, input().strip().split())
			ans = 1
			mod = int(1000000000.0 + 7)
			for i in range(2, int(math.sqrt(n)) + 2, 1):
				if n % i == 0:
					k = cnt(m, i)
					ans = ans * quickpow(i, k, mod) % mod
					while n % i == 0:
						n = n // i
			if n != 1:
				k = cnt(m, n)
				ans = ans * quickpow(n, k, mod) % mod
			print(ans)
		except EOFError:
			break
main()


def primes(x):
	ps = set()
	if not x % 2:
		ps.add(2)
	while not x % 2:
		x //= 2
	limit = int(x ** 0.5) + 1
	for i in range(3, limit, 2):
		if not x % i:
			ps.add(i)
		while not x % i:
			x //= i
	if x > 1:
		ps.add(x)
	return ps
(x, n) = map(int, input().split())
ps = primes(x)
ans = 1
modulo = 1000000007
for p in ps:
	p_k = p
	while p_k <= n:
		t = n // p_k
		ans *= pow(p, t, modulo)
		ans %= modulo
		p_k *= p
print(ans)


(x, n) = map(int, input().split())
prifa = []
tag = 1
while x > 2 and tag:
	tag = 0
	i = 2
	while i * i <= x:
		if x % i == 0:
			tag = 1
			while x % i == 0:
				x //= i
			prifa.append(i)
		i += 1
		if tag:
			break
if x > 1:
	prifa.append(x)
ans = 1
mod = 10 ** 9 + 7
for i in prifa:
	mi = 0
	tmp = n
	while tmp:
		mi += tmp // i
		tmp //= i
	ans *= pow(i, mi, mod)
	ans %= mod
print(ans)


ans = 1
MOD = 10 ** 9 + 7

def prime_factorize(num):
	prime_factor = {}
	i = 2
	while i ** 2 <= num:
		while num % i == 0:
			num //= i
			if i in prime_factor.keys():
				prime_factor[i] += 1
			else:
				prime_factor[i] = 1
		i += 1
	if num > 1:
		prime_factor[num] = 1
	return prime_factor

def divisorize(fct):
	(b, e) = fct.pop()
	pre_div = divisorize(fct) if fct else [[]]
	suf_div = [[(b, k)] for k in range(e + 1)]
	return [pre + suf for pre in pre_div for suf in suf_div]

def num(fct):
	a = 1
	for (base, exponent) in fct:
		a = a * base ** exponent
	return a
(x, n) = map(int, input().split())
pf = prime_factorize(x)
tar = []
for (k, v) in pf.items():
	tar.append(k)
for i in range(len(tar)):
	t = tar[i]
	beki = []
	e = 1
	while t * e <= n:
		beki.append(t * e)
		e = t * e
	beki.sort(reverse=True)
	beki_cnt = 0
	for j in range(len(beki)):
		be = beki[j]
		ans *= pow(be, n // be - beki_cnt, MOD)
		ans %= MOD
		beki_cnt += n // be - beki_cnt
print(ans)


def divisor(d):
	ret = []
	i = 2
	while i * i <= d:
		if d % i == 0:
			ret.append(i)
			while d % i == 0:
				d //= i
		i += 1
	if d > 1:
		ret.append(d)
	return ret
MOD = pow(10, 9) + 7
(x, n) = map(int, input().split())
ans = 1
for p in divisor(x):
	pw = 0
	fact = p
	while fact <= n:
		pw += n // fact
		fact *= p
	ans = ans * pow(p, pw, MOD) % MOD
print(ans)


def primefactor(p):
	x = p
	pf = []
	for i in range(2, int(p ** 0.5) + 1):
		if x % i == 0:
			pf.append(i)
			while x % i == 0:
				x //= i
	if x > 1:
		pf.append(x)
	return pf
ans = 1
MOD = int(1000000000.0 + 7)
(x, n) = list(map(int, input().split()))
for p in primefactor(x):
	exp = 0
	P = p
	while P <= n:
		exp += n // P
		P *= p
	ans *= pow(p, exp, MOD)
	ans %= MOD
print(ans)


def make_prime_factors2(n):
	prime_factors = []
	for k in range(2, int(n ** 0.5) + 1):
		cnt = 0
		while n % k == 0:
			cnt += 1
			n = n // k
		if cnt != 0:
			prime_factors.append((k, cnt))
	if n != 1:
		prime_factors.append((n, 1))
	return prime_factors
(x, n) = map(int, input().split())
x_prime = make_prime_factors2(x)
ans = 1
MOD = 10 ** 9 + 7
for (num, cnt) in x_prime:
	ruijo = 0
	while True:
		if num ** (ruijo + 1) <= n:
			ruijo += 1
		else:
			break
	li = []
	for i in range(ruijo):
		tmp_ruijo = ruijo - i
		cnt_num = n // num ** tmp_ruijo
		li.append(cnt_num)
		tmp = 0
		for (i, tmp_num) in enumerate(li[::-1]):
			if i == 0:
				tmp += tmp_num
			if i == 1:
				tmp -= tmp_num
		a1 = pow(num, tmp_ruijo, MOD)
		a2 = pow(a1, tmp, MOD)
		ans *= a2
		ans %= MOD
print(ans % MOD)


(n, m) = map(int, input().split())
s = []
x = n
for i in range(2, int(n ** 0.5) + 1):
	if x % i == 0:
		s.append(i)
		while x % i == 0:
			x = x // i
if x != 1:
	s.append(x)

def get(n, x):
	cnt = 0
	start = x
	while True:
		get = n // start
		if get == 0:
			break
		cnt += get
		start = start * x
	return cnt
ans = 1
mod = 10 ** 9 + 7
for i in s:
	gg = pow(i, get(m, i), mod)
	ans = ans * gg % mod
print(ans)


def primefactors(n):
	primes = []
	if n % 2 == 0:
		primes.append(2)
		while n % 2 == 0:
			n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			primes.append(i)
			while n % i == 0:
				n = n // i
	if n != 1:
		primes.append(n)
	return primes
(x, n) = map(int, input().split())
primes = primefactors(x)
ans = 1
for i in primes:
	divide = i
	while divide <= n:
		ans = ans * pow(i, n // divide, 1000000007) % 1000000007
		divide = divide * i
print(ans % 1000000007)


import sys
read = sys.stdin.buffer.readline
(x, n) = map(int, read().split())
i = 2
fac = []
while i * i <= x:
	if x % i == 0:
		fac.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	fac.append(x)
ans = []
for el in fac:
	(ct, z) = (0, 1)
	prd = el
	while prd <= n:
		d = n // prd
		ct += z * d
		ct -= d * (z - 1)
		z += 1
		prd *= el
	ans.append(ct)
md = 1000000007
ct = 1
for i in range(len(fac)):
	ct *= pow(fac[i], ans[i], md)
	ct %= md
print(ct)


def getPrimes(x):
	primes = []
	if x % 2 == 0:
		primes.append(2)
		while x % 2 == 0:
			x //= 2
	i = 3
	while i * i <= x:
		if x % i == 0:
			primes.append(i)
			while x % i == 0:
				x //= i
		i += 2
	if x > 2:
		primes.append(x)
	return primes

def calculate(x: int, n: int):
	primes = getPrimes(x)
	res = 1
	m = 10 ** 9 + 7
	for prime in primes:
		f = prime
		power = 0
		while f <= n:
			power += n // f
			f *= prime
		res *= pow(prime, power, m)
		res %= m
	return res
(x, n) = [int(i) for i in input().split()]
print(calculate(x, n))


import math
import sys
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = prime[1] = False
	r = [p for p in range(n + 1) if prime[p]]
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def pfact(n):
	r = []
	t = 1
	while n % 2 == 0:
		if t != 2:
			t = 2
			r.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			if t != i:
				t = i
				r.append(i)
			n = n // i
	if n > 2:
		r.append(n)
	return r

def getp(n, p):
	r = 0
	t = p
	while t <= n:
		r += n // t
		t *= p
	return r

def power(x, y, p):
	res = 1
	x = x % p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
m = 10 ** 9 + 7
(x, n) = mi()
pd = pfact(x)
res = 1
for i in pd:
	p = getp(n, i)
	res = res * power(i, p, m) % m
print(res % m)


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

def mu(a, b):
	if b == 0:
		return 1
	temp = mu(a, b // 2)
	temp = temp * temp % mod
	if b % 2:
		temp = temp * a % mod
	return temp

def d(x, a, b):
	return x // a - x // (a * b)

def phantich(n):
	res = []
	w = int(math.sqrt(n)) + 1
	for i in range(2, w):
		if n % i == 0:
			res.append(i)
		while n % i == 0:
			n //= i
	if n > 1:
		res.append(n)
	return res
p = phantich(x)
answer = 1
for w in p:
	temp = w
	while n >= temp:
		q = d(n, temp, w)
		answer = answer * mu(temp, q) % mod
		temp = temp * w
print(answer)


def getFactors(X):
	factors = []
	d = 2
	while d * d <= X:
		if X % d == 0:
			factors.append(d)
			while X % d == 0:
				X //= d
		d += 1
	if X > 1:
		factors.append(X)
	return factors

def main(X, N):
	factors = getFactors(X)
	result = 1
	mod = 1000000007
	for factor in factors:
		num = factor
		power = 0
		while num <= N:
			power += N // num
			num *= factor
		m = pow(factor, power, mod)
		result *= m
		result %= mod
	return result
(x, n) = [int(i) for i in input().split()]
print(main(x, n))


def primes(n):
	primfac = []
	d = 2
	while d * d <= n:
		while n % d == 0:
			primfac.append(d)
			n //= d
		d += 1
	if n > 1:
		primfac.append(n)
	return primfac
mod = 10 ** 9 + 7
ans = 1
(x, n) = map(int, input().split())
for i in set(primes(x)):
	f = i
	an = 0
	cnt = n // i
	while cnt:
		an += cnt
		f *= i
		cnt = n // f
	ans = ans * pow(i, an, mod) % mod
print(ans % mod)


import itertools as it
import math
from functools import reduce
import operator
try:
	from string_source import string_source
	source = string_source('947 987654321987654321')
except ImportError:
	source = input
PRIME = int(10 ** 9 + 7)

def times_appear(p, n):
	total = 0
	px = p
	while px <= n:
		total += n // px
		px *= p
	return total

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i == 0:
			factors.append(i)
			while n % i == 0:
				n //= i
		else:
			i += 1
	if n > 1:
		factors.append(n)
	return factors

def prod(x):
	return reduce(lambda x, y: x * y % PRIME, x, 1)

def solve(x, n):
	ps = prime_factors(x)
	return prod((pow(p, times_appear(p, n), PRIME) for p in ps))
print(solve(*map(int, source().split())))


MOD = 1000000007

def modexp(v, k):
	res = 1
	while k:
		if k & 1:
			res = res * v % MOD
		k >>= 1
		v = v * v % MOD
	return res
(x, n) = map(int, input().split())
div = dict()
from math import sqrt
sq = sqrt(x)
i = 2
while i <= sq:
	if x % i == 0:
		if i not in div:
			div[i] = 1
		else:
			div[i] += 1
		x //= i
		sq = sqrt(x)
	else:
		i += 1
if x not in div:
	div[x] = 1
else:
	div[x] += 1
ans = 1
for p in div:
	cnt = div[p]
	val = p
	c = 0
	while val <= n:
		c = c + n // val
		val *= p
	ans = ans * modexp(p, c) % MOD
print(ans)


MOD = 10 ** 9 + 7
(x, n) = [int(item) for item in input().split()]

def prime_factorize(n):
	b = 2
	fct = set()
	while b * b <= n:
		while n % b == 0:
			n //= b
			fct.add(b)
		b = b + 1
	if n > 1:
		fct.add(n)
	return fct
fac = prime_factorize(x)
ans = 1
for f in fac:
	cnt = 0
	val = n
	while val:
		cnt += val // f
		val //= f
	ans *= pow(f, cnt, MOD)
	ans %= MOD
print(ans)


def abc(n, c):
	ans = 0
	i = 0
	j = 200
	while i <= j:
		mid = i + (j - i) // 2
		if c ** mid <= n:
			ans = mid
			i = mid + 1
		else:
			j = mid - 1
	return ans
(x, n) = map(int, input().split())
import math

def primeFactors(n):
	l = []
	if n % 2 == 0:
		l.append(2)
	while n % 2 == 0:
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			l.append(i)
		while n % i == 0:
			n = n // i
	if n > 2:
		l.append(n)
	return l
l = primeFactors(x)
ans = 1
e = 10 ** 9 + 7
for i in l:
	c = i
	m = 0
	while c <= n:
		m += n // c
		c *= i
	x = pow(i, m, e)
	ans = ans * x % e
print(ans)


(x, n) = input().split(' ')
(x, n) = (int(x), int(n))
primes = []
for i in range(2, 100000):
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x = x // i
if x != 1:
	primes.append(x)
result_list = []
MOD = 1000000007
for p in primes:
	result = 0
	pk = p
	while pk <= n:
		result += n // pk
		pk *= p
	result_list.append((result, p))

def power(a, b):
	nonlocal MOD
	if b == 0:
		return 1
	r = 1
	ak = a
	while b > 0:
		if b % 2 == 1:
			r *= ak
		b = b // 2
		ak *= ak
		ak %= MOD
		r %= MOD
	return r
result = 1
for (r, p) in result_list:
	result *= power(p, r)
	result %= MOD
print(result)


import math
MOD = 1000000007

def powr(n, N):
	temp = 1
	while N > 0:
		if N % 2 != 0:
			temp = temp * n % MOD
		n = n * n % MOD
		N = N // 2
	return temp % MOD
(x, n) = map(int, input().split())
n1 = x
L = []
while n1 % 2 == 0:
	L.append(2)
	n1 = n1 // 2
for i in range(3, int(math.sqrt(n1)) + 1, 2):
	while n1 % i == 0:
		L.append(i)
		n1 = n1 // i
if n1 > 2:
	L.append(n1)
L = list(set(L))
mul = 1
for i in range(0, len(L)):
	d = L[i]
	nn = n
	while nn > 0:
		mul = mul * powr(d, nn // d) % MOD
		nn = nn // d
print(mul)


def prime(x):
	a = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			a.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		a.append(x)
	return a
(x, n) = list(map(int, input().split()))
a = prime(x)
l = 1
MOD = 10 ** 9 + 7
for i in a:
	p = i
	q = 0
	while p <= n:
		q += n // p
		p = p * i
	l = l * pow(i, q, MOD) % MOD
print(l)


import math

def prime(n):
	res = []
	if n % 2 == 0:
		res.append(2)
		while n % 2 == 0:
			n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			res.append(i)
			while n % i == 0:
				n = n // i
	if n > 2:
		res.append(n)
	return res

def high(n, p):
	x = 0
	while n > 0:
		n = n // p
		x += n
	return x
(x, n) = map(int, input().split())
res = prime(x)

def powe(a, b, mod):
	res = 1
	a = a % mod
	while b > 0:
		if b & 1 == 1:
			res = res * a % mod
		b = b >> 1
		a = a * a % mod
	return res
ans = 1
for a in res:
	val = high(n, a)
	ans = ans * powe(a, val, 1000000007) % 1000000007
print(ans)


(x, n) = map(int, input().split())
primes = []
i = 2
while i * i <= x:
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x = x // i
	i += 1
if x > 1:
	primes.append(x)
ans = 1
mod = 1000000007
for val in primes:
	value = val
	step = 0
	while value <= n:
		step += n // value
		value *= val
	ans = ans * pow(val, step, mod) % mod
print(ans)


import math

def prime(x):
	if x == 0 or x == 1:
		return 0
	if x == 2:
		return 1
	else:
		for i in range(2, int(math.sqrt(x)) + 1):
			if x % i == 0:
				return 0
		return 1
(x, n) = [int(x) for x in input().split()]
pdiv = []
for i in range(1, int(math.sqrt(x)) + 1):
	if x % i == 0:
		if i * i == x:
			if prime(i):
				pdiv.append(i)
		else:
			if prime(i):
				pdiv.append(i)
			if prime(x // i):
				pdiv.append(x // i)
ans = 1
for i in pdiv:
	power = 0
	temp = n
	while temp > 0:
		temp //= i
		power += temp
	tt = pow(i, power, 10 ** 9 + 7)
	ans = ans * tt % (10 ** 9 + 7)
print(ans)


def prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			return False
		i += 1
	return True

def powmod(a, b, p):
	if b == 0:
		return 1
	if b % 2 == 0:
		x = powmod(a, b // 2, p)
		return x * x % p
	return a * powmod(a, b - 1, p) % p
(x, n) = map(int, input().split())
factor = set()
while x > 1:
	if prime(x):
		factor.add(x)
		break
	i = 2
	while i * i <= x:
		if x % i == 0:
			x = x // i
			factor.add(i)
			break
		i += 1
ans = 1
MOD = 10 ** 9 + 7
for p in factor:
	P = p
	while P <= n:
		cnt = n // P
		X = powmod(p, cnt, MOD)
		ans = ans * X
		ans = ans % MOD
		P *= p
print(ans)


(x, nn) = map(int, input().split())
n = x
s = []
if n % 2 == 0:
	s.append(2)
while n % 2 == 0:
	n = n // 2
import math
i = 3
while i <= int(math.sqrt(n)):
	if n % i == 0:
		s.append(i)
	while n % i == 0:
		n = n // i
	i += 1
if n > 1:
	s.append(n)
ans = 1
for i in s:
	k = i
	su = 0
	while k <= nn:
		su = nn // k
		k *= i
		ans *= pow(i, su, 1000000007)
		ans %= 1000000007
print(ans)


import math
import os
import sys
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
MOD = 10 ** 9 + 7

def mpow(a, n):
	p = a
	v = 1
	while n > 0:
		if n & 1:
			v *= p
			v %= MOD
		n >>= 1
		p *= p
		p %= MOD
	return v

def solve(X, Y):
	ps = []
	x = X
	for p in range(2, X + 1):
		if p * p > x:
			break
		if x % p == 0:
			ps.append(p)
			x //= p
			while x % p == 0:
				x //= p
	if x > 1:
		ps.append(x)
	ans = 1
	for p in ps:
		times = 0
		q = p
		while q <= Y:
			times += Y // q
			q *= p
		ans *= mpow(p, times)
		ans %= MOD
	return ans

def main():
	(X, Y) = [int(e) for e in inp().split()]
	print(solve(X, Y))
main()


(x, n) = map(int, input().split())
mod = 1000000007
res = 1

def bpow(x, y):
	res = 1
	while y > 0:
		if y % 2 == 1:
			res = res * x % mod
			y -= 1
		else:
			x = x * x % mod
			y //= 2
	return res
sp = []
i = 2
while i * i <= x:
	if x % i == 0:
		sp.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	sp.append(x)
for i in sp:
	st = 1
	while st <= n:
		st *= i
	st //= i
	byv = 0
	while st > 0:
		cnk = n // st
		cnk -= byv
		res = res * bpow(st, cnk) % mod
		byv += cnk
		st //= i
print(res)


(x, n) = map(int, input().split())
f = []
i = 2
while i * i <= x:
	if x % i == 0:
		f.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	f.append(x)
mod = int(1000000000.0 + 7)

def ksm(a, k):
	ret = 1
	while k > 0:
		if k & 1:
			ret = ret * a % mod
		a = a * a % mod
		k >>= 1
	return ret
ans = 1
for p in f:
	pp = p
	while pp <= n:
		ans *= ksm(pp, n // pp - n // (p * pp))
		ans %= mod
		pp *= p
print(ans)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))

def prime_factorize(n):
	if n == 1:
		return [1]
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
(x, n) = inpl()
res = 1
for prr in list(set(prime_factorize(x))):
	now = prr
	while now <= n:
		cnt = n // now
		res *= pow(prr, cnt, mod)
		res %= mod
		now *= prr
print(res)


[x, n] = input().split(' ')
x = int(x)
n = int(n)
mod = 1000000007
primes = []

def is_prime(n):
	if n < 2:
		return False
	if n == 2:
		return True
	if n % 2 == 0:
		return False
	i = 3
	while i * i <= n:
		if n % i == 0:
			return False
		i += 2
	return True

def fast_pow(a, b):
	r = 1
	while b > 0:
		if b & 1 == 1:
			r = r * a % mod
		a = a * a % mod
		b //= 2
	return r

def query(p):
	ans = 1
	v = p
	while v <= n:
		ans = ans * fast_pow(p, n // v) % mod
		v *= p
	return ans
ans = 1
if is_prime(x):
	ans = query(x)
else:
	i = 2
	while x > 1 and i * i <= x:
		if x % i != 0:
			i += 1
			continue
		ans = ans * query(i) % mod
		while x % i == 0:
			x //= i
		i += 1
	if x > 1:
		ans = ans * query(x) % mod
print(ans)


MOD = int(1000000000.0 + 7)

def factpow(n, k):
	res = 0
	while n:
		n //= k
		res += n
	return res

def primes(n):
	res = []
	for i in range(2, min(n, int(n ** 0.5) + 2)):
		if not n % i:
			res.append(i)
			while not n % i:
				n //= i
	if n != 1:
		res.append(n)
	return res
(x, n) = map(int, input().split())
res = 1
for p in primes(x):
	res *= pow(p, factpow(n, p), MOD)
	res %= MOD
print(res)


import math

def primeFactors(n):
	prime = list()
	while n % 2 == 0:
		prime.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.append(i)
			n = n // i
	if n > 2:
		prime.append(n)
	return set(prime)
(x, n) = map(int, input().split())
d = primeFactors(x)
if len(d) == 0:
	d.append(x)
ans = 1
for ele in d:
	(temp, pw) = (ele, 0)
	while n // temp > 0:
		pw += n // temp
		temp = temp * ele
	ans = ans * pow(ele, pw, 10 ** 9 + 7) % (10 ** 9 + 7)
print(ans)


from math import sqrt
modu = int(1000000000.0) + 7

def binpow(a, n):
	if n == 0:
		return 1
	if n % 2 == 1:
		return binpow(a, n - 1) * a % modu
	else:
		b = binpow(a, n // 2)
		return b * b % modu
(x, n) = list(map(int, input().split(' ')))
primes = []
for i in range(2, int(sqrt(x) + 2)):
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x //= i
if x != 1:
	primes.append(x)
ans = 1
for prime in primes:
	cur = prime
	while cur <= n:
		power = n // cur - n // (cur * prime)
		ans = ans * binpow(cur, power) % modu
		cur *= prime
print(ans)


(x, n) = input().split(' ')
x = int(x)
n = int(n)
mod = int(1000000000.0) + 7

def dec(x):
	y = x
	i = 2
	a = []
	while i * i <= x:
		if y % i == 0:
			a.append(i)
			while y % i == 0:
				y //= i
		i += 1
	if y > 1:
		a.append(y)
	return a

def qpow(a, p):
	r = 1
	while p:
		if p & 1:
			r = r * a % mod
		a = a * a % mod
		p >>= 1
	return r
pf = dec(x)
ans = 1
for p in pf:
	(j, qaq, qwq) = (0, 1, p)
	tmp = 0
	while qaq <= n:
		t = j * ((n // qaq - n // qwq) % (mod - 1)) % (mod - 1)
		tmp = (tmp + t) % (mod - 1)
		qaq = qaq * p
		qwq = qwq * p
		j += 1
	ans = ans * qpow(p, tmp) % mod
print(ans)


from sys import stdin
from math import sqrt
mod = pow(10, 9) + 7
(x, n) = map(int, stdin.readline().split())
primes = []
for i in range(2, int(sqrt(x)) + 4):
	if x % i == 0:
		primes.append(i)
	while x % i == 0:
		x //= i
if x != 1:
	primes.append(x)
res = 1
for p in primes:
	cur = p
	while cur <= n:
		res *= pow(p, n // cur, mod)
		res %= mod
		cur *= p
print(res)


def isprime(a):
	for i in range(2, int(a ** 0.5) + 1):
		if a % i == 0:
			return 0
	return 1
(x, y) = map(int, input().split())
a = x
i = 2
l = []
while i <= a ** 0.5:
	if isprime(i) == 1 and a % i == 0:
		while a % i == 0:
			a = a // i
		l.append(i)
	else:
		i += 1
if isprime(a) == 1 and a != 1:
	l.append(a)
prod = 1
for i in l:
	j = 1
	while True:
		if y // i ** j != 0:
			prod = prod * pow(i, y // i ** j, 1000000007) % 1000000007
			j += 1
		else:
			break
print(prod)


import math

def prime_factorization(n):
	ps = set()
	i = 2
	while i * i <= n:
		if n % i == 0:
			ps.add(i)
			while n % i == 0:
				n //= i
		i += 1
	if n >= 2:
		ps.add(n)
	return ps
(x, n) = map(int, input().split())
ps = prime_factorization(x)
z = 1
modulo = 10 ** 9 + 7
for i in ps:
	c = 0
	small_n = 0.1 ** 14
	for j in range(int(math.log(n, i) + small_n), 0, -1):
		f = i ** j
		nf = n // f
		z *= pow(f, nf - c, modulo)
		c = nf
print(z % modulo)


from math import sqrt, ceil

def primes(x):
	ox = x
	l = []
	cp = 3
	if x % 2 == 0:
		l.append(2)
	while x % 2 == 0:
		x //= 2
	while cp <= ceil(sqrt(ox)):
		if x % cp == 0:
			l.append(cp)
		while x % cp == 0:
			x //= cp
		cp += 2
	if x != 1:
		l.append(x)
	return l
mo = 10 ** 9 + 7
(x, n) = map(int, input().split())
pi = primes(x)
s = 1
for p in pi:
	pk = p
	while pk <= n:
		s *= pow(p, n // pk, mo)
		s %= mo
		pk *= p
print(s)


from math import sqrt, ceil

def primes(n):
	c = n
	l = []
	i = 3
	if n % 2 == 0:
		l.append(2)
	while n % 2 == 0:
		n = n // 2
	while i <= ceil(sqrt(c)):
		if n % i == 0:
			l.append(i)
		while n % i == 0:
			n = n // i
		i += 2
	if n != 1:
		l.append(n)
	return l
mo = 10 ** 9 + 7
(n, m) = map(int, input().split())
prime = primes(n)
ans = 1
for p in prime:
	k = p
	while k <= m:
		ans *= pow(p, m // k, mo)
		ans = ans % mo
		k *= p
print(ans)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
(x, n) = lin()
md = 10 ** 9 + 7

def factors(a):
	fact = []
	if a % 2 == 0:
		while a % 2 == 0:
			a //= 2
		fact.append(2)
	i = 3
	while i * i <= a:
		if a % i == 0:
			while a % i == 0:
				a //= i
			fact.append(i)
		i += 2
	if a > 1:
		fact.append(a)
	return fact
fact = factors(x)
ans = 1
for f in fact:
	x = f
	ch = 0
	while x <= n:
		ch += n // x
		x *= f
	ans = ans * pow(f, ch, md)
	ans %= md
ans = ans % md
print(ans)


def power(a, b):
	mod = 10 ** 9 + 7
	if b == 0:
		return 1
	temp = power(a, b // 2)
	temp %= mod
	temp = temp * temp
	temp %= mod
	if b % 2 == 1:
		temp *= a
	temp %= mod
	temp = (temp + mod) % mod
	return temp
(x, n) = map(int, input().split())
primes = []
i = 2
while i * i <= x:
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x != 1:
	primes.append(x)
ans = 1
mod = 10 ** 9 + 7
i = 0
for i in range(len(primes)):
	y = 1
	p = primes[i]
	while True:
		if y * p > n:
			break
		y *= p
	prev = 0
	while y > 1:
		ans *= power(y, n // y - prev)
		prev = n // y
		ans %= mod
		y //= p
ans = (ans + mod) % mod
ans = int(ans)
print(ans)


def prime_factorize(n):
	prime = []
	p = 2
	while p * p <= n:
		if n % p == 0:
			prime.append(p)
			while n % p == 0:
				n //= p
		p += 1
	if n > 1:
		prime.append(n)
	return prime

def solve(X, N):
	prime_factors = prime_factorize(X)
	(ans, mod) = (1, 10 ** 9 + 7)
	for factor in prime_factors:
		expo = 0
		prime = factor
		while factor <= N:
			expo += N // factor
			factor *= prime
		ans *= pow(prime, expo, mod)
		ans %= mod
	return ans
(X, N) = map(int, input().split())
print(solve(X, N))


import math
(x, n) = map(int, input().split())
maxPrime = int(math.sqrt(x) + 1)
isPrime = [True] * maxPrime
primes = []
for i in range(2, maxPrime):
	if x % i == 0:
		primes.append(i)
	while x % i == 0:
		x = x // i
if x > 1:
	primes.append(x)
sol = 1

def quickPow(x, power):
	if power == 1:
		return x
	ans = quickPow(x, power // 2)
	ans *= ans
	if power % 2 == 1:
		ans *= x
	return ans % 1000000007
for prime in primes:
	i = prime
	while i <= n:
		sol = sol * quickPow(prime % 1000000007, n // i) % 1000000007
		i *= prime
print(sol)


(x, n) = list(map(int, input().split()))
mod = 10 ** 9 + 7
pf = []
p = int(x ** 0.5) + 1
for i in range(2, p):
	if x % i == 0:
		pf.append(i)
		while x % i == 0:
			x = x // i
if x != 1:
	pf.append(x)
ans = 1
for i in pf:
	cur = i
	while cur <= n:
		ans = ans * pow(i, n // cur, mod) % mod
		cur = cur * i
print(ans)


import sys
input = sys.stdin.readline
(x, n) = map(int, input().split())
ans = 1
M = 10 ** 9 + 7

def exp(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a % M
		a = a * a % M
		b >>= 1
	return res
i = 2
while i * i <= x:
	if x % i == 0:
		while x % i == 0:
			x //= i
		cnt = 0
		foo = n
		while foo:
			foo //= i
			cnt += foo
		ans = ans * exp(i, cnt) % M
	i += 1
if x > 1:
	cnt = 0
	foo = n
	while foo:
		foo //= x
		cnt += foo
	ans = ans * exp(x, cnt) % M
print(ans)


MOD = 10 ** 9 + 7
(x, n) = list(map(int, input().split()))

def calc_exponents(n, p):
	exp = 0
	while n > 0:
		exp += n // p
		n = n // p
	return pow(p, exp, MOD)
primes = []
p = 2
while p * p <= x:
	if x % p == 0:
		primes.append(p)
		while x % p == 0:
			x = x // p
	p = p + 1
if x > 1:
	primes.append(x)
answer = 1
for p in primes:
	answer *= calc_exponents(n, p) % MOD
print(answer % MOD)


(x, n) = [int(x) for x in input().split()]
from math import sqrt, ceil, log
primes = [0] * (10 ** 4 * 6)
for i in range(2, len(primes)):
	if primes[i] == 0:
		primes[i] = i
		for j in range(2 * i, len(primes), i):
			primes[j] = -1
Primes = []
for prime in primes:
	if prime >= 2:
		Primes.append(prime)
primes = Primes

def containspower(base, num):
	(l, r) = (0, int(log(num, base) + 1))
	while r - l > 1:
		c = (l + r) // 2
		if num % base ** c == 0:
			l = c
		else:
			r = c
	return l

def factor(x):
	ans = []
	for i in primes:
		if x % i == 0:
			ans.append((i, containspower(i, x)))
			x //= i ** ans[-1][1]
	if x != 1:
		ans.append((x, 1))
	return ans
xx = factor(x)
ans = 1
for (p, power) in xx:
	pa = 1
	for i in range(1, int(log(n, p)) + 5):
		a = pow(p, n // p ** i, 10 ** 9 + 7)
		pa *= a if a != 0 else 1
	ans *= pa
	ans %= 10 ** 9 + 7
print(ans % (10 ** 9 + 7))


prime = 1000000007
from math import sqrt
(x, n) = list(map(int, input().split()))
count = 0
tmp = n
ans = 1
if x % 2 == 0:
	count = 0
	tmp = n
	while tmp > 1:
		tmp = tmp // 2
		count += tmp
	ans = ans * pow(2, int(count), prime) % prime
while x % 2 == 0:
	x = x >> 1
for i in range(3, int(sqrt(x)) + 1, 2):
	if x % i == 0:
		count = 0
		tmp = n
		while tmp > 1:
			tmp = tmp // i
			count += tmp
		ans = ans * pow(int(i), int(count), prime) % prime
	while x % i == 0:
		x = x / i
if x > 2:
	count = 0
	tmp = n
	while tmp > 1:
		tmp = tmp // x
		count += tmp
	ans = ans * pow(int(x), int(count), prime) % prime
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

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

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	(x, n) = sep()
	primes = []
	for i in range(1, floor(x ** 0.5) + 1):
		if x % i == 0:
			if isPrime(i):
				primes.append(i)
			if x // i != i and isPrime(x // i):
				primes.append(x // i)
	ans = 1
	for i in range(len(primes)):
		temp = 0
		lol = 0
		while primes[i] ** (temp + 1) <= n:
			lol += n // primes[i] ** (temp + 1)
			temp += 1
		ans *= power(primes[i], lol, mod)
		ans %= mod
	print(ans % mod)
testcase(1)


def bin(x, n, p):
	ret = 1
	while n != 0:
		if n & 1:
			ret = ret * x % p
		x = x * x % p
		n //= 2
	return ret

def fac(x, dic):
	i = 2
	while i * i <= x:
		if x % i == 0:
			dic.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x != 1:
		dic.append(x)
	return

def hdl(k, n):
	cur = k
	ret = 0
	while cur <= n:
		ret = ret + n // cur
		cur *= k
	return ret
dic = []
(a, b) = map(int, input().strip().split())
fac(a, dic)
ret = 1
mod = 1000000007
for j in dic:
	ret = ret * bin(j, hdl(j, b), mod) % mod
print(ret % mod)


from math import sqrt

def primes(n):
	L = []
	if not n & 1:
		n >>= 1
		while not n & 1:
			n >>= 1
		L.append(2)
	for i in range(3, int(sqrt(n)) + 1, 2):
		if n % i == 0:
			L.append(i)
			n //= i
			while n % i == 0:
				n //= i
	if n > 1:
		L.append(n)
	return L

def fact_pow(n, p):
	ans = 0
	while n:
		ans += n // p
		n //= p
	return ans

def binpow(a, n, p):
	if n == 0:
		return 1
	if n == 1:
		return a % p
	x = binpow(a, n >> 1, p)
	return x * x * a % p if n & 1 else x * x % p
ans = 1
mod = 1000000007
(x, n) = map(int, input().split())
L = primes(x)
for p in L:
	ans = ans * binpow(p, fact_pow(n, p), mod) % mod
print(ans)


import sys
M = 1000000007
(x, n) = map(int, input().split(' '))
ft = set()
while x != 1:
	i = 2
	while x % i != 0 and i * i <= x:
		i += 1
	if x % i != 0:
		ft.add(int(x))
		break
	else:
		ft.add(i)
		x /= i
ans = 1
for i in ft:
	pp = i
	while pp <= n:
		ans *= pow(int(i), int(n // pp), M)
		ans %= M
		pp *= i
print(ans)


from itertools import chain
from math import sqrt
ub = 10 ** 5
ub_sqrt = int(sqrt(ub)) + 1
primes = {2, 3} | set(chain(range(5, ub, 6), range(7, ub, 6)))
du = primes.difference_update
for n in chain(range(5, ub_sqrt, 6), range(7, ub_sqrt, 6)):
	if n in primes:
		du(range(n * 3, ub, n * 2))
(x, n) = map(int, input().split())
divisors = []
for p in primes:
	if x % p == 0:
		divisors.append(p)
		while x % p == 0:
			x //= p
if x > 1:
	divisors.append(x)
ans = 1
mod = 10 ** 9 + 7
for d in divisors:
	cur = d
	while cur <= n:
		ans = ans * pow(d, n // cur, mod) % mod
		cur *= d
print(ans)


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
(x, n) = map(int, input().split())
r = int(x ** 0.5)
(ans, p) = (1, 2)
primes = set()
while p <= r and p <= x:
	while x % p == 0:
		primes.add(p)
		x = int(x / p)
	p += 1
if x > 1:
	primes.add(x)
for prime in primes:
	e = []
	p = prime
	while p <= n:
		a = n // p
		if len(e) == 0:
			e.append(a)
		else:
			e[len(e) - 1] -= a
			e.append(a)
		p *= prime
	total_expo = 0
	i = 1
	for expo in e:
		total_expo += expo * i
		i += 1
	ans = ans * power(prime, total_expo, 1000000007)
	ans %= 1000000007
print(ans)


from math import log
m = 10 ** 9 + 7
factors = []

def primefactors(n):
	global factors
	while n % 2 == 0:
		factors += [2]
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2):
		while n % i == 0:
			factors += [i]
			n = n // i
	if n > 2:
		factors += [n]
	factors = list(set(factors))
(x, n) = map(int, input().split())
primefactors(x)
ans = 1
for i in factors:
	k = int(log(n) / log(i)) + 2
	num = []
	p = i
	for j in range(k):
		num += [p]
		p *= i
		if p > n:
			break
	num = num[::-1]
	times = [n // num[0]]
	for j in range(1, k):
		try:
			times += [n // num[j] - n // num[j - 1]]
		except:
			break
	for h in range(len(num)):
		ans = ans * pow(num[h], times[h], m) % m
print(ans)


def primefactors(x):
	ans = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			ans.append(i)
			while x % i == 0:
				x = x // i
		i = i + 1
	if x > 1:
		ans.append(x)
	return ans
(x, n) = [int(c) for c in input().split()]
prime = primefactors(x)
MOD = 1000000007
ans = 1
for x in prime:
	p = 0
	tmp = x
	while tmp <= n:
		p = p + n // tmp
		tmp = tmp * x
	ans = ans * pow(x, p, MOD)
ans = ans % MOD
print(ans)


import math

def prime(n):
	t = []
	if n % 2 == 0:
		t.append(2)
	while n % 2 == 0:
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		if n % i == 0:
			t.append(i)
		while n % i == 0:
			n = n / i
	if n > 2:
		t.append(int(n))
	return t

def cn(n, p):
	c = 0
	i = p
	while n >= i:
		c += n // i
		i *= p
	return c
(x, n) = map(int, input().split())
p = prime(x)
ans = 1
for i in p:
	k = cn(n, i)
	temp = pow(i, k, 1000000007)
	ans *= temp % (10 ** 9 + 7)
	ans %= 10 ** 9 + 7
print(ans)


(x, n) = map(int, input().split())
primes = []
p = 2
while p * p <= x:
	if x % p == 0:
		primes.append(p)
		while x % p == 0:
			x //= p
	p += 1
if x > 1:
	primes.append(x)
res = 1
for p in primes:
	val = 0
	exp = n
	while exp:
		exp //= p
		val += exp
	res = res * pow(p, val, 10 ** 9 + 7) % (10 ** 9 + 7)
print(res)


mod = 10 ** 9 + 7

def fa(n):
	z = n
	i = 2
	ans = []
	while i * i <= z:
		while n % i == 0:
			if len(ans) == 0 or ans[-1] != i:
				ans.append(i)
			n //= i
		i += 1
	if n > 1:
		ans.append(n)
	return ans

def s(n, a):
	z = a
	cnt = 0
	while z <= n:
		cnt += n // z
		z *= a
	return pow(a, cnt, mod)
(x, n) = [int(x) for x in input().split()]
ans = 1
for z in fa(x):
	ans *= s(n, z)
	ans %= mod
print(ans)


(x, n) = map(int, input().split())
mod = 10 ** 9 + 7
p = []
for i in range(2, int(x ** 0.5) + 1):
	if x % i == 0:
		p.append(i)
		while x % i == 0:
			x //= i
if x != 1:
	p.append(x)
ans = 1
for pp in p:
	cnt = 0
	k = pp
	while k <= n:
		cnt += n // k
		k *= pp
	ans = ans * pow(pp, cnt, mod) % mod
print(ans)


import math
MOD = int(10 ** 9 + 7)

def calc(n, d):
	res = 0
	while n:
		res = res + n // d
		n //= d
	return int(pow(d, res, MOD))
(x, n) = map(int, input().split())
sq = int(math.sqrt(x)) + 1
ans = 1
for d in range(2, sq):
	cnt = 0
	while x % d == 0:
		cnt += 1
		x //= d
	if cnt > 0:
		ans = ans * calc(n, d) % MOD
if x > 1:
	ans = ans * calc(n, x) % MOD
print(int(ans))


(a, n) = [int(i) for i in input().split()]
L = set()
i = 2
while i * i <= a:
	if a % i == 0:
		L.add(i)
		while a % i == 0:
			a //= i
	i += 1
if a >= 2:
	L.add(a)
mod = 10 ** 9 + 7
ans = 1
for xx in L:
	ct = 0
	pw = xx
	while pw <= n:
		ct += n // pw
		pw *= xx
	ans = ans * pow(xx, ct, mod) % mod
print(ans)


from collections import defaultdict as dc
import sys
import math
mod = 10 ** 9 + 7

def inp():
	p = sys.stdin.readline()
	return p

def prf(n):
	p = []
	c = 0
	while n % 2 == 0:
		n = n // 2
		c += 1
	if c > 0:
		p.append(2)
	for i in range(3, int(n ** 0.5) + 1, 2):
		c = 0
		while n % i == 0:
			n = n // i
			c += 1
		if c > 0:
			p.append(i)
	if n > 2:
		p.append(n)
	return p
(x, n) = list(map(int, inp().split()))
l = prf(x)
ans = 1
for i in range(len(l)):
	p = l[i]
	c = 0
	lim = n // l[i]
	while p <= n:
		c = c + n // p
		if p > lim:
			break
		p = p * l[i]
	ans = ans * pow(l[i], c, mod) % mod
print(ans)


import math

def divide(b):
	divs = []
	x = int(b)
	for i in range(2, int(math.sqrt(x) + 1)):
		if int(x) % int(i) == 0:
			divs.append(int(i))
			while int(x) % int(i) == 0:
				x = int(x) // int(i)
	if x > 1:
		divs.append(x)
	return divs

def pow_(n, k, mod):
	ret = 1
	while int(k) > 0.9:
		if int(k) % int(2) == 1:
			ret = int(ret) * int(n) % int(mod)
		n = int(n) * int(n) % int(mod)
		k = int(k) // int(2)
	return ret
mod = 1000000007
(x, n) = input().split()
x = int(x)
n = int(n)
if n > 1:
	listdiv = divide(x)
	ans = 1
	kk = []
	for i in range(len(listdiv)):
		nn = n
		temp = 0
		while True:
			temp = int(temp) + int(nn) // int(listdiv[i])
			nn = int(nn) // int(listdiv[i])
			if int(nn) < 1:
				break
		ans *= int(pow_(listdiv[i], temp, mod))
		ans %= int(mod)
	print(ans)
else:
	print(1)


def prime(n):
	i = 2
	factors = []
	flag = False
	while i * i <= n:
		if n % i:
			i += 1
		else:
			factors.append(i)
			while n % i == 0:
				n //= i
	if n > 1:
		factors.append(n)
	return factors

def get_h(n, p, result):
	if n > 0:
		return get_h(n // p, p, result + n // p)
	return result

def run():
	(x, n) = list(map(int, input().split()))
	prime_factors = prime(x)
	c = 1
	mod_val = 10 ** 9 + 7
	for p in prime_factors:
		h = get_h(n, p, 0)
		c *= pow(p, h, mod_val)
	c = c % mod_val
	print(c)
run()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 10 ** 9 + 7
INF = float('inf')
from math import sqrt, ceil

def prim(num):
	up = ceil(sqrt(num))
	res = []
	if num == 1:
		return res
	for i in range(2, up + 1):
		if num % i == 0:
			while num % i == 0:
				num //= i
			res.append(i)
			if num == 1:
				break
	else:
		res.append(num)
	return res

def main():
	(x, n) = RL()
	pri = prim(x)
	res = 1
	for p in pri:
		tn = n
		while p <= tn:
			res = res * pow(p, tn // p, mod) % mod
			tn //= p
	print(res % mod)
main()


def solve(n, z):
	n1 = n
	count = 0
	ans = 0
	while n != 0:
		n = n // z
		count += 1
	prev = 0
	for i in range(count, 0, -1):
		j = z ** i
		z1 = (n1 - j) // j + 1
		yo = z1 - prev
		prev += yo
		ans += i * yo
	return ans
import math

def primeFactors(n):
	ans = []
	while n % 2 == 0:
		ans.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			ans.append(int(i))
			n = n / i
	if n > 2:
		ans.append(int(n))
	return ans
mod = 10 ** 9 + 7
(x, n) = map(int, input().split())
z = primeFactors(x)
z = sorted(set(list(z)))
fin = 1
for i in z:
	k = solve(n, i)
	fin *= pow(i, k, mod)
print(fin % mod)


def factorize(n):
	factors = []
	for i in range(2, int(n ** 0.5) + 1):
		cnt = 0
		while n % i == 0:
			n //= i
			cnt += 1
		if cnt > 0:
			factors.append((i, cnt))
	if n > 1:
		factors.append((n, 1))
	return factors
(x, n) = map(int, input().split())
factors = factorize(x)
ans = 1
MOD = 10 ** 9 + 7
for (p, _) in factors:
	max_k = 0
	while p ** max_k <= n:
		max_k += 1
	prev_c = 0
	for k in range(max_k, -1, -1):
		c = n // p ** k
		ans *= pow(pow(p, k, MOD), c - prev_c, MOD)
		ans %= MOD
		prev_c = c
print(ans)


import sys

def is_prime(n):
	if n == 1:
		return (False, 1)
	i = 2
	while i * i <= n:
		if n % i == 0:
			return (False, i)
		i += 1
	return (True, n)

def fact(n):
	if n == 1:
		return []
	ans = []
	tmp = is_prime(n)
	while not tmp[0]:
		while n % tmp[1] == 0:
			n = n // tmp[1]
		ans.append(tmp[1])
		tmp = is_prime(n)
		if tmp[1] == 1:
			break
	ans.append(n)
	return ans

def legendre(x, n):
	ans = 0
	tmpx = x
	while n // tmpx > 0:
		ans += n // tmpx
		tmpx *= x
	return ans

def fastpow(x, pow):
	if pow == 0:
		return 1
	if pow % 2 == 0:
		tmp = fastpow(x, pow // 2)
		return tmp ** 2 % 1000000007
	else:
		return x * fastpow(x, pow - 1) % 1000000007
(x, n) = input().split()
x = int(x)
n = int(n)
ans = 1
for i in fact(x):
	if i != 1:
		ans = ans * fastpow(i, legendre(i, n)) % (10 ** 9 + 7)
print(ans)


import sys
sys.setrecursionlimit(100)
(x, n) = list(map(int, sys.stdin.readline().split()))
primes = []
import math

def divide(n):
	isprime = 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			isprime = i
			break
	if isprime == 0:
		primes.append(n)
	else:
		primes.append(i)
		divide(n // i)
divide(x)
primes = set(primes)

def ans(p, c):
	if c == 0:
		return 1
	if c == 1:
		return p
	if c % 2 == 0:
		return ans(p, c // 2) ** 2 % 1000000007
	else:
		return ans(p, c // 2) ** 2 * p % 1000000007
answer = 1
for p in primes:
	ex = 0
	nn = n
	while nn > 1:
		ex += nn // p
		nn = nn // p
	answer = answer * ans(p, ex) % 1000000007
print(answer)


primeFact = set()

def facto(n):
	while n % 2 == 0:
		primeFact.add(2)
		n //= 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			primeFact.add(i)
		while n % i == 0:
			n //= i
	if n > 1:
		primeFact.add(n)
(x, n) = map(int, input().split())
(ans, modulo) = (1, 10 ** 9 + 7)
facto(x)
for i in primeFact:
	(pows, k) = (0, i)
	while n // k >= 1:
		pows += n // k
		k *= i
	ans = ans * pow(i, pows, modulo) % modulo
print(ans)


import math
m = int(pow(10, 9)) + 7
(a, b) = map(int, input().split())
l = []
for i in range(2, int(a ** 0.5) + 1):
	while a % i == 0:
		l.append(i)
		while a % i == 0:
			a = a // i
if a != 1:
	l.append(a)
c = 1
for i in l:
	j = i
	while b >= j:
		c = c * pow(i, b // j, m)
		c = c % m
		j *= i
print(c % m)


import math

def get_primes(v):
	if v == 2 or v == 4:
		return [2]
	if v == 3:
		return [3]
	res = []
	for i in range(2, int(v ** 0.5) + 1):
		if v % i == 0:
			res.append(i)
			while v % i == 0:
				v //= i
	if v > 1:
		res.append(v)
	return res

def bin_search_pow(prime, value):
	(l, r) = (-1, int(math.log(value, prime)) + 2)
	while r - l > 1:
		m = (r + l) // 2
		if pow(prime, m) > value:
			r = m
		else:
			l = m
	return l
mod = 10 ** 9 + 7
(x, n) = map(int, input().split())
ans = 1
px = get_primes(x)
for p in px:
	s = 0
	m = bin_search_pow(p, n)
	for i in range(m, 0, -1):
		pwr = n // pow(p, i) - s
		s += pwr
		ans = ans * pow(p, i * pwr, mod) % mod
print(ans)


import math
inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
MOD = 1000000007
(x, n) = inp()
P = set()
nn = x
for i in range(2, math.ceil(math.sqrt(x)) + 1):
	if nn % i == 0:
		P.add(i)
	while nn % i == 0:
		nn //= i
P.add(nn)
if 1 in P:
	P.remove(1)
res = 1
for g in P:
	ccc = 0
	if x % g == 0:
		j = g
		while j <= n:
			ccc += n // j
			j *= g
		res = res * pow(g, ccc, MOD) % MOD
print(res)


def primeFactors(n):
	import math
	ans = []
	while n % 2 == 0:
		(ans.append(2),)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			ans.append(int(i))
			n = n / i
	if n > 2:
		ans.append(int(n))
	return list(set(ans))

def PowerOFPINnfactorial(n, p):
	ans = 0
	temp = p
	while temp <= n:
		ans += n // temp
		temp = temp * p
	return int(ans)

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
bc = list(map(int, input().split()))
b = bc[0]
c = bc[1]
primelist = primeFactors(b)
ans = 1
for i in primelist:
	temp = PowerOFPINnfactorial(c, i)
	ans = ans * power(i, temp, 1000000007)
print(ans % 1000000007)


from math import floor, sqrt

def pp(a, b, c):
	r = 1
	a %= c
	while b:
		if b & 1:
			r = r * a % c
		b >>= 1
		a = a * a % c
	return r
(n, x) = [int(i) for i in input().split()]
d = n
l = []
h = floor(sqrt(d))
MOD = 1000000007
if d % 2 == 0:
	l += [2]
	while d % 2 == 0:
		d //= 2
for i in range(3, h + 1, 2):
	if d % i == 0:
		l += [i]
	while d % i == 0:
		d //= i
if d > 2:
	l += [d]
ans = 1
for i in l:
	f = i
	s = 0
	while f <= x:
		s += x // f
		f *= i
	ans = ans * pp(i, s, MOD) % MOD
print(ans)


def prime_factorization(x):
	primes = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			primes.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		primes.append(x)
	return primes

def solve(x, n):
	mod = 10 ** 9 + 7
	answer = 1
	primes = prime_factorization(x)
	for prime in primes:
		power = 0
		factor = prime
		while factor <= n:
			power += n // factor
			factor *= prime
		answer *= pow(prime, power, mod)
		answer %= mod
	return answer
(x, n) = [int(e) for e in input().split()]
print(solve(x, n))


prime = []
mod = 10 ** 9 + 7

def get_prime(x):
	i = 2
	while i * i <= x:
		if x % i == 0:
			prime.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		prime.append(x)

def solve(x, n):
	ans = 1
	get_prime(x)
	for item in prime:
		power = 0
		tmpp = item
		while tmpp <= n:
			power += n // tmpp
			tmpp *= item
		ans *= pow(item, power, mod)
		ans %= mod
	print(ans)
(x, n) = [int(i) for i in input().split()]
solve(x, n)


md = int(1000000000.0 + 7)

def bin_pow(n, k):
	if k == 0:
		return 1
	if k % 2 == 0:
		t = bin_pow(n, k // 2)
		return t * t % md
	else:
		t = bin_pow(n, k // 2)
		return t * t % md * n % md
(x, n) = map(int, input().split())
prime = []
i = 2
while i * i <= x:
	if x % i == 0:
		prime.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	prime.append(x)
ans = 1
for p in prime:
	t = p
	k = 1
	while t <= n:
		t *= p
		k += 1
	cur = 1
	pow_p = p
	for i in range(1, k + 1):
		cur *= bin_pow(pow_p, n // pow_p - n // pow_p // p)
		cur %= md
		pow_p *= p
	ans *= cur
	ans %= md
print(ans)


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

def is_prime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
d = []
i = 1
mod = 1000000007
while i * i <= x:
	if x % i == 0:
		if is_prime(i):
			d.append([i, 0])
		if i != x // i and is_prime(x // i):
			d.append([x // i, 0])
	i += 1
ans = 1
for i in range(len(d)):
	p = d[i][0]
	while p <= n:
		d[i][1] += n // p
		p *= d[i][0]
	ans *= pow(*d[i], mod)
	ans %= mod
print(ans)


MOD = 10 ** 9 + 7

def isi(n):
	ck = False
	tmp = int(n ** 0.5) + 1
	for i in range(2, tmp):
		if n % i == 0:
			return False
	return True

def fast(n, k):
	res = 1
	n %= MOD
	while k > 0:
		if k & 1 == 1:
			res = res * n % MOD
		k = k >> 1
		n = n * n % MOD
	return res
(a, b) = map(int, input().split())
fac = set()
tmp = int(a ** 0.5) + 1
for i in range(2, tmp):
	if a % i == 0:
		if isi(i):
			fac.add(i)
		if isi(a / i):
			fac.add(a // i)
if isi(a):
	fac.add(a)
ans = 1
for x in list(fac):
	y = x
	c = 0
	while y <= b:
		c = c + b // y
		y *= x
	ans = ans * fast(x, c) % MOD
print(ans)


def factorize(k):
	i = 2
	pf = []
	while k > 1 and i * i <= k:
		if k % i == 0:
			pf.append(i)
			while k % i == 0:
				k //= i
		i += 1
	if k > 1:
		pf.append(k)
	return pf
MOD = int(1000000000.0 + 7)
(x, n) = map(int, input().split())
ans = 1
pf = factorize(x)
for fc in pf:
	p = fc
	cnt = 0
	while p <= n:
		ub = n // p * p
		cnt += (ub - p) // p + 1
		p *= fc
	ans *= pow(fc, cnt, MOD)
	ans %= MOD
print(ans)


(x, n) = [int(x) for x in input().split()]
prime = set()
arr = 1
y = int(x ** 0.5)
for i in range(2, y + 1):
	while x % i == 0:
		prime.add(i)
		x //= i
if x != 1:
	prime.add(x)
dic = {}
for item in prime:
	dic[item] = 0
for item in prime:
	for i in range(1, 60):
		dic[item] += n // item ** i
for item in dic:
	arr *= pow(item, dic[item], 10 ** 9 + 7)
print(arr % (10 ** 9 + 7))


M = int(1000000000.0 + 7)
(x, n) = map(int, input().split())

def prime_factorize(n):
	primes_factors = set()
	while n % 2 == 0:
		n >>= 1
		primes_factors.add(2)
	for i in range(3, int(n ** (1 / 2)) + 1, 2):
		while n % i == 0:
			n //= i
			primes_factors.add(i)
	if n > 1:
		primes_factors.add(n)
	return primes_factors
ans = 1
for d in prime_factorize(x):
	(g, r) = (0, n)
	while r:
		r //= d
		g += r
	ans *= pow(d, g, M)
	ans %= M
print(ans)


import math

def primeFactors(n):
	primes = set()
	while n % 2 == 0:
		primes.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			primes.add(i)
			n = n // i
	if n > 2:
		primes.add(n)
	return primes
mod = 1000000007
(x, n) = list(map(int, input().split()))
factors = list(primeFactors(x))
factors.sort()
ans = 1
for i in range(0, len(factors)):
	temp = factors[i]
	while temp <= n:
		p = (n - temp) // temp + 1
		ans = ans * pow(factors[i], p, mod) % mod
		temp = temp * factors[i]
print(ans)


inp = input().split()
x = int(inp[0])
n = int(inp[1])
p = 7 + 10 ** 9
ps = []
for d in range(2, 100001):
	if x % d == 0:
		ps.append(d)
	while x % d == 0:
		x //= d
if x != 1:
	ps.append(x)
ans = 1
for pr in ps:
	cur = 0
	ppow = pr
	while n >= ppow:
		cur += n // ppow
		ppow *= pr
	ans *= pow(pr, cur, p)
	ans %= p
print(ans % p)


import heapq
from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
(X, Y) = list(map(int, input().split()))

def primeFact_set(n):
	factors = set()
	i = 2
	while i * i <= n:
		if n % i == 0:
			n //= i
			if i <= Y:
				factors.add(i)
		else:
			i += 1
	if n > 1 and n <= Y:
		factors.add(n)
	return factors
X_prime = primeFact_set(X)
MOD = 10 ** 9 + 7
ans = 1
for p in X_prime:
	tmp = p
	while tmp <= Y:
		div = Y // tmp
		ans *= pow(p, div, MOD)
		ans %= MOD
		tmp *= p
print(ans)


mod = 10 ** 9 + 7

def power(x, y):
	if y == 0:
		return 1
	x_ = power(x, y // 2)
	if y & 1:
		return x_ * x_ % mod * x % mod
	else:
		return x_ * x_ % mod
(x, n) = [int(i) for i in input().split()]
primes = []
i = 2
while i <= int(x ** (1 / 2)):
	if x % i == 0:
		primes.append(i)
		while x % i == 0:
			x //= i
	i += 1
if x > 1:
	primes.append(x)
ans = 1
for prime in primes:
	curr = 1
	while curr * prime <= n:
		curr *= prime
	last = 0
	while curr > 1:
		temp = n // curr
		temp -= last
		last += temp
		temp = power(curr, temp)
		ans = ans * temp % mod
		curr //= prime
print(ans)


def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primefactors(n):
	s = set()
	if isprime(n):
		s.add(n)
		return s
	i = 2
	while i * i <= n:
		if n % i == 0 and isprime(i):
			s.add(i)
			while n % i == 0:
				n //= i
			if isprime(n):
				s.add(n)
		i += 1
	return s
(x, n) = map(int, input().split(' '))
s = primefactors(x)

def maxp(n, i):
	ans = 0
	t = i
	while n // i > 0:
		ans += n // i
		i *= t
	return ans

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
ans = 1
for i in s:
	ans = ans * power(i, maxp(n, i), 1000000007) % 1000000007
print(ans)


MOD = 1000000007

def Pow(a, e):
	if e == 0:
		return 1
	if e == 1:
		return a
	temp = Pow(a, e // 2)
	temp = temp * temp % MOD
	if e % 2 == 1:
		temp = temp * a % MOD
	return temp
(x, n) = input().split()
x = int(x)
n = int(n)
i = 2
V = []
while i * i <= x:
	if x % i == 0:
		V.append(i)
	while x % i == 0:
		x = x // i
	i = i + 1
if x != 1:
	V.append(x)
res = 1
for v in V:
	tmp = 1
	while tmp * v <= n:
		tmp = tmp * v
		cnt = n // tmp
		cnt = cnt - cnt // v
		res = res * Pow(tmp, cnt) % MOD
print(res)


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
listin = lambda : list(map(int, input().split()))
mapin = lambda : map(int, input().split())

def primeFactors(n):
	s = []
	count = 0
	while n % 2 == 0:
		count += 1
		n //= 2
	if count:
		s.append(2)
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		count = 0
		while n % i == 0:
			count += 1
			n //= i
		if count:
			s.append(i)
	if n > 2:
		s.append(n)
	return s
(x, n) = mapin()
ans = 1
z = primeFactors(x)
for i in z:
	count = 0
	d = i
	while d <= n:
		count += n // d
		d *= i
	if count:
		ans *= pow(i, count, 1000000007)
		ans %= 1000000007
print(ans)


(x, y) = map(int, input().split())
sift_max = 600000
prime = [True] * sift_max
prime[0] = True
primes = []
for i in range(2, sift_max):
	if not prime[i]:
		continue
	primes.append(i)
	for j in range(i * 2, sift_max, i):
		prime[j] = False
prime_x = []
for d in primes:
	if d * d > x:
		break
	if x % d == 0:
		prime_x.append(d)
		while x % d == 0:
			x //= d
if x != 1:
	prime_x.append(x)
func = 1
for p in prime_x:
	p_k = p
	p_pow = 0
	while p_k <= y:
		p_pow += y // p_k
		p_k *= p
	pow2pow = [0] * 65
	pow2pow[1] = p
	for i in range(2, 65):
		if p_pow % 2:
			func = func * pow2pow[i - 1] % 1000000007
		pow2pow[i] = pow2pow[i - 1] ** 2 % 1000000007
		p_pow //= 2
print(func)


def prime_factorization(x: int):
	primes = []
	i = 2
	while i * i <= x:
		if x % i == 0:
			primes.append(i)
			while x % i == 0:
				x //= i
		i += 1
	if x > 1:
		primes.append(x)
	return primes

def solution(x: int, n: int):
	result = 1
	primes = prime_factorization(x)
	for p in primes:
		value = p
		power = 0
		while value <= n:
			power += n // value
			value *= p
		result *= pow(p, power, 10 ** 9 + 7)
	return result % (10 ** 9 + 7)
(x, n) = input().split()
print(str(solution(int(x), int(n))))


mod = 1000000007

def sqrat(n):
	x = n
	y = (x + 1) // 2
	while y < x:
		x = y
		y = (x + n // x) // 2
	return x

def paw(e, exp):
	if exp == 0:
		return 1
	if exp == 1:
		return e
	ret = paw(e, exp // 2)
	l = ret * ret % mod
	if exp % 2 == 1:
		l *= e
		l %= mod
	return l

def main():
	inp = input().split()
	x = int(inp[0])
	n = int(inp[1])
	prime = set()
	cur = x
	for i in range(2, sqrat(x) + 5):
		while cur % i == 0:
			cur //= i
			prime.add(i)
	if cur > 1:
		prime.add(cur)
	p = 1
	for e in prime:
		f = e
		exp = 0
		while f <= n:
			exp += n // f
			f *= e
		p *= paw(e, exp)
		p %= mod
	print(p)
main()


import math
(x, n) = map(int, input().split())
se = set({})
if x % 2 == 0:
	se.add(2)
	while x % 2 == 0:
		x //= 2
for i in range(3, int(x ** (1 / 2)) + 1, 2):
	if x % i == 0:
		se.add(i)
		while x % i == 0:
			x //= i
if x != 1:
	se.add(x)
ans = 1
mod = 1000000007
for i in se:
	xx = n
	while i <= xx:
		ans = ans * pow(i, xx // i, mod) % mod
		xx //= i
print(ans)


(x, n) = [x for x in map(int, input().split())]
L = set()
a = 2
while a ** 2 <= x:
	if x % a == 0:
		L.add(a)
		while x % a == 0:
			x //= a
	a += 1
if x >= 2:
	L.add(x)
mod = 10 ** 9 + 7
res = 1
for i in L:
	h = 0
	b = i
	while b <= n:
		h += n // b
		b *= i
	res = res * pow(i, h, mod) % mod
print(res)


import sys
import os
import math

def READ(fileName):
	sys.stdin = open('in.txt')

def sieve():
	primes = []
	M = 100007
	marked = [0 for x in range(M)]
	sz = int(math.sqrt(M))
	for i in range(3, sz, 2):
		if marked[i] == 0:
			for j in range(i * i, M, 2 * i):
				marked[j] = 1
	primes.append(2)
	for i in range(3, M, 2):
		if marked[i] == 0:
			primes.append(i)
	return primes

def g(x, p):
	cnt = 0
	while x != 0:
		cnt += x // p
		x //= p
	res = pow(p, cnt, 1000000007)
	return res
mod = 1000000007
while True:
	try:
		(x, n) = map(int, input().split())
	except EOFError:
		break
	primes = sieve()
	factors = []
	for prime in primes:
		if x % prime == 0:
			factors.append(prime)
			while x % prime == 0:
				x //= prime
	if x > 1:
		factors.append(x)
	res = 1
	for factor in factors:
		res = res % mod * (g(n, factor) % mod) % mod
	print(res)
pass


(x, n) = map(int, input().split())
prime_factors = []
for i in range(2, int(x ** 0.5) + 1):
	if x % i == 0:
		prime_factors.append(i)
		while x % i == 0:
			x = x // i
if x > 1:
	prime_factors.append(x)
ans = 1
mod = int(1000000000.0) + 7
for i in prime_factors:
	base = i
	while base <= n:
		ans = ans * pow(i, n // base, mod) % mod
		base = base * i
print(ans)


def binpow(a, n, m):
	if n == 0:
		return 1
	if n & 1 == 1:
		return a * binpow(a, n - 1, m) % m
	else:
		b = binpow(a, n // 2, m)
		return b * b % m

def factorize(a):
	res = []
	i = 2
	while i * i <= a:
		if a % i == 0:
			res.append(i)
			while a > 1 and a % i == 0:
				a //= i
		i += 1
	if a > 1:
		res.append(a)
	return res
(x, n) = map(int, input().split())
f = factorize(x)
rs = 1
for i in range(len(f)):
	cn = 0
	ee = f[i]
	while ee <= n:
		cn += n // ee
		ee *= f[i]
	rs = rs * binpow(f[i], cn, 1000000007) % 1000000007
print(rs)


import math

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

def primeFactors(n):
	a = []
	while n % 2 == 0:
		(a.append(2),)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			(a.append(int(i)),)
			n = n / i
	if n > 2:
		a.append(int(n))
	return a
(x, n) = map(int, input().split())
k = primeFactors(x)
d = set(k)
p = 1
q = 1000000007
for i in d:
	j = i
	sum = 0
	while j <= n:
		sum += n // j
		j *= i
	p *= power(i, sum, q) % 1000000007
print(p % 1000000007)


(x, n) = map(int, input().split())
xx = x
l = {}
d = 2
while x > 1 and d ** 2 <= xx:
	if x % d == 0:
		x //= d
		l[d] = 0
	else:
		d += 1
if x != 0:
	l[x] = 0
primes = list(l.keys())
powers = []
for p in primes:
	wyk = 0
	for w in range(1, 100):
		wyk += n // p ** w
	powers.append(wyk)
wyn = 1

def pot(a, n):
	mn = a
	wyn = 1
	while n > 0:
		if n % 2 == 1:
			wyn = wyn * mn % (10 ** 9 + 7)
		mn = mn ** 2 % (10 ** 9 + 7)
		n //= 2
	return wyn
for i in range(len(powers)):
	wyn = wyn * pot(primes[i], powers[i]) % (10 ** 9 + 7)
print(wyn)


import math

def factorize(n):
	count = 0
	li = []
	while (n % 2 > 0) == False:
		n >>= 1
		count += 1
	if count > 0:
		li.append(2)
	for i in range(3, int(math.sqrt(n)) + 1):
		count = 0
		while n % i == 0:
			count += 1
			n = int(n / i)
		if count > 0:
			li.append(i)
		i += 2
	if n > 2:
		li.append(n)
	return li
(x, n) = map(int, input().split())
s = factorize(x)
ans = 1
m = 10 ** 9 + 7

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
ns = len(s)
for j in range(ns):
	p = 0
	c = s[j]
	i = 1
	while c <= n:
		p += n // c
		i += 1
		c = s[j] ** i
	ans = ans * power(s[j], p, m) % m
print(ans)


import math
divisor = int(math.pow(10, 9)) + 7

def solution():
	(x, n) = map(int, input().split())
	primes = get_primes(x)
	res = 1
	for prime in primes:
		res = res * (helper(prime, n) % divisor) % divisor
	print(res)

def get_primes(x):
	primes = []
	i = 2
	limit = int(math.sqrt(x)) + 1
	while i < limit:
		if x % i == 0:
			primes.append(int(i))
			while x % i == 0:
				x = x / i
		else:
			i += 1
	if x > 1:
		primes.append(int(x))
	return primes

def helper(p, n):
	k = 1
	count = 0
	p_k = p
	while n >= p_k:
		count += n // p_k
		p_k = p_k * p
	res = pow(p, count, divisor)
	return res
solution()