n, k = [int(e) for e in input().split()]
result = 1
c = 1
modulo = 10 ** 9 + 7
k = min(k, n)
for m in range(1, k + 1):
    c = c * (n - m + 1) // m
    result += c
    result %= modulo
print(result)


MOD = 10**9 + 7
MAX_F = 10**5 + 5

fact = [1 for i in range(MAX_F)]
ifact = [1 for i in range(MAX_F)]

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

def power(a, n):
    if n == 0:
        return 1
    if n == 1:
        return a

    tmp = power(a, n // 2)
    if n % 2 == 0:
        return mult(tmp, tmp)
    return mult(a, mult(tmp, tmp))

def C(n, k):
    # https://www.geeksforgeeks.org/compute-ncr-p-set-3-using-fermat-little-theorem/
    if k < 0 or k > n:
        return 0
    # print(
    #     f"fact[{n}]={fact[n]}, ifact[{n-k}]={ifact[n-k]}, ifact[{k}]={ifact[k]}"
    # )
    return mult(fact[n], mult(ifact[n - k], ifact[k]))

def init():
    n = MAX_F - 1
    for i in range(1, n + 1):
        fact[i] = mult(fact[i - 1], i)

    ifact[n] = power(fact[n], MOD - 2)
    for i in range(n - 1, 0, -1):
        ifact[i] = mult(ifact[i + 1], i + 1)

init()
n, k = map(int, input().split())
res = 0
for m in range(min(n, k) + 1):
    # print(f"n={n}, m={m}, C({n},{m})={C(n,m)}")
    res += C(n, m)
print(res)


import math
n, k = map(int, input().split())
ans = 0
cur = 0
for i in range(0, min(n, k)+1):
    if i == 0:
        ans += 1
        cur = 1
    else:
        cur *= n - (i - 1)
        cur *= pow(i, -1, 1000000007)
        cur = cur % 1000000007
        ans += cur
print(ans)


#import io, os
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

dvcnt=[0 for _ in range(1000005)]

for i in range(1,len(dvcnt)):
    for j in range(i,len(dvcnt),i):
        dvcnt[j]+=1

n=int(input())
dp=[0,1]
for i in range(n):
    dp.append(2*dp[-1]+dvcnt[i+2]-dvcnt[i+1])
print(dp[n]%998244353)


#import sys

#comment these out later
#sys.stdin = open("in.in", "r")
#sys.stdout = open("out.out", "w")

MAX = 1000001;

# array to store
# prime factors
factor = [0]*(MAX + 1);

# function to generate all
# prime factors of numbers
# from 1 to 10^6
def generatePrimeFactors():
	factor[1] = 1;

	# Initializes all the
	# positions with their value.
	for i in range(2,MAX):
		factor[i] = i;

	# Initializes all
	# multiples of 2 with 2
	for i in range(4,MAX,2):
		factor[i] = 2;

	# A modified version of
	# Sieve of Eratosthenes
	# to store the smallest
	# prime factor that divides
	# every number.
	i = 3;
	while(i * i < MAX):
		# check if it has
		# no prime factor.
		if (factor[i] == i):
			# Initializes of j
			# starting from i*i
			j = i * i;
			while(j < MAX):
				# if it has no prime factor
				# before, then stores the
				# smallest prime divisor
				if (factor[j] == j):
					factor[j] = i;
				j += i;
		i+=1;

# function to calculate
# number of factors
def calculateNoOFactors(n):
	if (n == 1):
		return 1;
	ans = 1;

	# stores the smallest
	# prime number that
	# divides n
	dup = factor[n];

	# stores the count of
	# number of times a
	# prime number divides n.
	c = 1;

	# reduces to the next
	# number after prime
	# factorization of n
	j = int(n / factor[n]);

	# false when prime
	# factorization is done
	while (j > 1):
		# if the same prime
		# number is dividing
		# n, then we increase
		# the count
		if (factor[j] == dup):
			c += 1;

		# if its a new prime factor
		# that is factorizing n,
		# then we again set c=1 and
		# change dup to the new prime
		# factor, and apply the formula
		# explained above.
		else:
			dup = factor[j];
			ans = ans * (c + 1);
			c = 1;

		# prime factorizes
		# a number
		j = int(j / factor[j]);

	# for the last
	# prime factor
	ans = ans * (c + 1);

	return ans;

# This code is contributed
# by mits.

def calc(n):
	dp = [-1]*(n+1)
	dp[0] = 1
	dp[1] = 1

	pre = 2

	generatePrimeFactors()

	for i in range(2, n+1):
		dp[i] = pre + calculateNoOFactors(i) - 1

		pre += dp[i]

	return (dp[n])%998244353

n = int(input())

print(calc(n))


import os
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict,Counter
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations

sys.setrecursionlimit(100000000)

int_inp = lambda: int(input())  # integer input
strng = lambda: input().strip()  # string input
jn = lambda x, l: x.join(map(str, l))
strl = lambda: list(input().strip())  # list of strings as input
mul = lambda: map(int, input().strip().split())  # multiple integers as ipnut
mulf = lambda: map(float, input().strip().split())  # multiple floats as ipnut
seq = lambda: list(map(int, input().strip().split()))  # list of integers

ceil = lambda x: int(x) if (x == int(x)) else int(x) + 1  # celing function
ceildiv = lambda x, d: x // d if (x % d == 0) else x // d + 1

flush = lambda: stdout.flush()
stdstr = lambda: stdin.readline()
stdint = lambda: int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))

mod = 998244353
max_val=sys.maxsize
def divisorofn(n):
    factors = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            factors[j] += 1
    return factors[n]

def solve():
    n=int_inp()
    res=0
    s=0
    for i in range(1,n+1):
        res=(s+divisorofn(i))%mod
        s=(s+res)%mod
    print(res)

solve()


mod = 998244353

def divisorofn(n):
    factors = [0] * (n + 1)

    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            factors[j] += 1
    return factors[n]

def solve():
    n=int(input())
    res=0
    s=0
    for i in range(1,n+1):
        res=(s+divisorofn(i))%mod
        s=(s+res)%mod
    print(res)

solve()


mod = 998244353
n = int(input())
f = [0 for i in range(n + 1)]
f[1] = 1
sum = 0
init = [0 for i in range(n + 1)]
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        init[j] += 1
for i in range(2, n + 1):
    sum += f[i - 1]
    f[i] += sum + init[i]
print(f[n] % mod)


m=998244353
n,x=map(int,input().split())
if n>=x+1:
	print(pow(x,n,m))
else:
	print('a')
	f=[1]
	d=[1]
	for i in range(n):
		f.append(f[-1]*(i+1)%m)
		print('a')
		d.append(d[-1]*pow(i+1,-1,m)%m)
	t=[[0]*(n+1) for i in range(x+1)]
	c=[[0]*(n+1) for i in range(n+1)]
	for j in range(1,n+1):
		for k in range(j+1):
			c[j][k]=(pow(j-1,j-k,m)*f[j]*d[k]*d[j-k])%m
	for i in range(1,x+1):
		t[i][0]=1
		for j in range(2,n+1):
			if j>i:
				t[i][j]=pow(i,j,m)
			else:
				t[i][j]=sum(t[i-j+1][k]*c[j][k] for k in range(j+1))%m
	print(t[x][n])


m=998244353
n,x=map(int,input().split())
if n>=x+1:
	print(pow(x,n,m))
else:
	f=[1]
	d=[1]
	for i in range(n):
		f.append(f[-1]*(i+1)%m)
		d.append(d[-1]*pow(i+1,-1,m)%m)
	t=[[0]*(n+1) for i in range(x+1)]
	c=[[0]*(n+1) for i in range(n+1)]
	for j in range(1,n+1):
		for k in range(j+1):
			c[j][k]=(pow(j-1,j-k,m)*f[j]*d[k]*d[j-k])%m
	for i in range(1,x+1):
		t[i][0]=1
		for j in range(2,n+1):
			if j>i:
				t[i][j]=pow(i,j,m)
			else:
				t[i][j]=sum(t[i-j+1][k]*c[j][k] for k in range(j+1))%m
	print(t[x][n])


N,X = map(int,input().split())
mod = 998244353
C = [[0]*(N+1) for _ in range(N+1)]
for r in range(1,N+1):
    C[r][0] = 1
    for c in range(1,N+1):
        C[r][c] = C[r-1][c-1] + C[r-1][c]
        C[r][c] %= mod
dp = [[0] * (X+1) for _ in range(N+1)]
memo = [[1] * (N+1) for _ in range(N+1)]
for n in range(1,N+1):
    for a in range(1,N+1):
        memo[n][a] = memo[n][a-1] * n
        memo[n][a] %= mod
for x in range(1,X+1):
    dp[1][x] = 1
for n in range(2,N+1):
    for x in range(1,X+1):
        if x -(n-1) >= 1:
            for a in range(n):
                if dp[n-a][x-(n-1)]:
                    dp[n][x] += (dp[n-a][x-(n-1)] * C[n][a])%mod * memo[n-1][a]
                    dp[n][x] %= mod
DEL = 0
for x in range(1,X+1):
    DEL += dp[N][x]
    DEL %= mod
ans = pow(X,N,mod) - DEL
print(ans%mod)


from sys import stdin
input = stdin.readline

mod = 998244353
def ncr(n , r):return (fact[n] * (facti[r] * facti[n - r])%mod)%mod

fact , facti = [1] , [1]
size = 501
for i in range(1 , size):
    fact.append((fact[-1] * i)%mod)
    facti.append(pow(fact[-1] , mod - 2 , mod))

def solve(heroes , damage):

    if(heroes == 0):return 1
    if(heroes == 1):return 0
    if(damage >= x):return 0

    if(dp[heroes][damage] != -1):dp[heroes][damage]

    ans = 0
    for i in range(heroes + 1):

        ways = ncr(heroes , i) #i people are dead in next round
        value = pow(min(x - damage , heroes - 1) , i , mod)

        val = (ways * value * solve(heroes - i , damage + heroes - 1))%mod

        ans = (ans + val)%mod

    dp[heroes][damage] = ans
    return ans

def answer():

    ans = solve(n , 0)

    return ans

for T in range(1):
    n , x = map(int , input().split())

    #dp[i][j] -> i heros are alive with after recieving j damage
    dp = [[-1 for i in range(x + 1)] for j in range(n + 1)]

    print(answer())


from __future__ import division, print_function
import math
import sys
import os
from io import BytesIO, IOBase
#from collections import deque, Counter, OrderedDict, defaultdict
#import heapq
#ceil,floor,log,sqrt,factorial,pow,pi,gcd
#import bisect
#from bisect import bisect_left,bisect_right

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):
	"""Prints the values to a stream, or to sys.stdout by default."""
	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)

input = lambda: sys.stdin.readline().rstrip("\r\n")

def I():
    return(int(input()))
def lint():
    return(list(map(int,input().split())))
def insr():
    s = input().strip()
    return(list(s[:len(s)]))
def invr():
    return(map(int,input().split()))
import itertools
from sys import maxsize, stdout, stdin,stderr
mod = int(1e9+7)
import sys
# def I(): return int(stdin.readline())
# def lint(): return [int(x) for x in stdin.readline().split()]
def S(): return list(map(str,input().strip()))
def grid(r, c): return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop , heappush
import bisect
from math import factorial, inf
from itertools import groupby
from itertools import permutations as comb

mod=1000000007
MOD = 998244353
def gcd(a,b):
    while b:
        a %= b
        tmp = a
        a = b
        b = tmp

    return a

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

def check_prime(n):
    for i in range(2, int(n ** (1 / 2)) + 1):
        if not n % i:
            return False
    return True

# def nCr(n, r):

#     return (fact(n) // (fact(r)
#                 * fact(n - r)))

# Returns factorial of n
# def fact(n):

#     res = 1

#     for i in range(2, n+1):
#         res = res * i

#     return res
def primefactors(n):
    num=0

    while n % 2 == 0:
        num+=1
        n = n / 2

    for i in range(3,int(math.sqrt(n))+1,2):

        while n % i== 0:
            num+=1
            n = n // i

    if n > 2:
        num+=1
    return num
'''
def iter_ds(src):
    store=[src]
    while len(store):
        tmp=store.pop()
        if not vis[tmp]:
            vis[tmp]=True
            for j in ar[tmp]:
                store.append(j)
'''
def ask(a,b,c):
    # print('? 1 {}'.format(a),flush=True)
    print(c,a,b,flush=True)
    n=I()

    return n
def linear_sieve(n):
    is_composite=[False]*n
    prime=[]
    for i in range(2,n):
        if not is_composite[i]:
            prime.append(i)
        for j in prime:
            is_composite[i*j]=True
            if i%prime==0:
                break
    return prime

def dfs(i,p,d):

    a,tmp=0,0
    for j in d[i]:
        if j!=p:
            a+=1
            tmp+=dfs(j,i)

    if a==0:
        return 0

    return tmp/a + 1
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 l

def binpow(a,b,c=MOD):
    res=1
    a=a%c
    while b>0:
        if b&1:
            res=(res*a)%c

        b=b>>1
        a = (a*a)%c

    return res

#  Sieve
d=[]
primes=[]
prim=[0]*(10**5+1)
def sieve(n):

    for i in range(n):
        d.append(i)

    for i in range(2,n):

        if d[i]==i:
            prim[i]=1
            primes.append(i)
        j=0
        while j<len(primes) and primes[j]<=d[i] and primes[j]*i<n:

            d[i * primes[j]] = primes[j]
            j+=1

def primeFactors(n):
    factors=[]
    while n!=1:
        factors.append(d[n])
        n//=d[n]

    return factors

fact=[0 for _ in range(501)]
def prefact():
    fact[0]=1
    fact[1]=1
    for i in range(2,501):
        fact[i]=fact[i-1]*i

dp=[[-1 for i in range(501)] for j in range(501)]
def nCr(n, r):
    return (fact[n]//(fact[r]*fact[n-r]))%MOD

def fun(n, x):

    if n==0:
        return 1
    if x<n:
        return binpow(x,n,MOD)
    if dp[n][x]!=-1:
        return dp[n][x]
    curr=0;
    for i in range(n+1):
        if i == n-1:
            continue
        curr+= ((nCr(n,i)*binpow(n-1,i,MOD))%MOD * fun(n-i,x-n+1))%MOD

        curr%=MOD

    dp[n][x]=curr

    return curr

t = 1
# t = I()
for _ in range(t):
    n,x=lint()
    prefact()

    fun(n,x)
    print(dp[n][x])


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

dic = {}
counts = [0]*22

for i in range(1,22):
    b = 0
    for j in range(1,n+1):
        b += i
        dic[b] = 1

    counts[i] = len(dic)

visited = [False]*(n+1)

ans = 1
for r in range(2,m+1):

    if visited[r]: continue

    p = 1
    num = r

    while num*r <= n:
        num *= r
        p += 1
        visited[num] = True

    ans += counts[p]
#    print(r,ans)

print(ans)


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

dic = {}
counts = [0]*22

for i in range(1,22):
    b = 0
    for j in range(1,n+1):
        b += i
        dic[b] = 1

    counts[i] = len(dic)

#print(counts)

visited = [False]*(m+1)

ans = 1
for r in range(2,m+1):

    if visited[r]: continue

    p = 1
    num = r

    while num*r <= m:
        num *= r
        p += 1
        visited[num] = True

#    print(p)

    ans += counts[p]
#    print(r,ans)

print(ans)


import math

def main():
    n, m = list(map(int, input().split(' ')))
    max_base = [[0, 0] for _ in range(n+1)]
    for i in range(2, int(math.sqrt(n)) + 1):
        for j in range(2, 100):
            tmp = pow(i, j)
            if tmp > n:
                break
            max_base[tmp][0] = i
            max_base[tmp][1] = j
    res = 1
    s = [0] * (m * (int(math.log2(n))) + 1)
    f = [0] * (int(math.log2(n) + 1))
    num = 0
    for i in range(1, int(math.log2(n) + 1)):
        for j in range(1, m + 1):
            if s[i * j] == 0:
                num += 1
                s[i * j] = 1
        f[i] = num
    for i in range(2, n + 1):
        if max_base[i][1] == 0:
            #print(i, int(math.log2(n) - math.log2(i)))
            #print(i, n, math.log(n, i))
            res += f[int(math.log(n, i))]

    print(res)

    return

main()


import math

def main():
    n, m = list(map(int, input().split(' ')))
    max_base = [[0, 0] for _ in range(n+1)]
    min_base = [[0, 0] for _ in range(n+1)]
    for i in range(2, int(math.sqrt(n)) + 1):
        for j in range(2, 100):
            tmp = pow(i, j)
            if tmp > n:
                break
            max_base[tmp][0] = i
            max_base[tmp][1] = j
            if min_base[tmp][0] == 0:
                min_base[tmp][0] = i
                min_base[tmp][1] = j
    res = 1
    s = set()
    f = [0] * (int(math.log2(n) + 1))
    for i in range(1, int(math.log2(n) + 1)):
        for j in range(1, m + 1):
            s.add(i * j)
        f[i-1] = len(s)
    #print(f)
    for i in range(2, n + 1):
        if max_base[i][1] == 0:
            #print(i, int(math.log2(n) - math.log2(i)))
            res += f[int(math.log2(n) - math.log2(i))]

    print(res)

    return

main()


import sys
input = sys.stdin.buffer.readline

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

ans = n*m
doublecount = m-1

for i in range(2, n+1):
    tot = 0
    pow = i
    while pow <= n:
        tot += 1
        pow *= i

    for i in range(1, tot+1):
        for j in range(2*i, tot+1, i):
            log_ratio = j//i
            doublecount += m//log_ratio

print(ans-doublecount)


def naive(n, m):
    vi = set()
    for i in range(1, n + 1):
        for j in range(1, m + 1):
            vi.add(i ** j)
            # print(i ** j)
    return len(vi)

# find unique cnts in this table:
#     1 2 3  4.. m
#     2 4 6  8..
#     3 6 9  12
#     4 8 12 16
#     n 2n 3n .. nm
# Note that n is only up to ~ 20 while m can go to 1e6.
tableCnts = [-1] * 22

def main():

    n, m = readIntArr()

    tableVi = [False] * (22 * (m + 1) + 5)
    cnt = 0
    for i in range(1, 22):
        for j in range(1, m + 1):
            x = i * j
            if tableVi[x] == False:
                tableVi[x] = True
                cnt += 1
        tableCnts[i] = cnt

    ans = 1 # for 1st row
    vi = [False] * (n + 1)

    for i in range(2, n + 1):
        if vi[i] == False:
            N = 0
            j = i
            while j <= n:
                vi[j] = True
                N += 1
                j *= i
            ans += tableCnts[N]
            # print('i:{} N:{} change:{}'.format(i, N, tableCnts[N]))
    print(ans)

    # print('naive:{}'.format(naive(n, m)))

    return

import sys
input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)
# input=lambda: sys.stdin.readline().rstrip("\r\n") #FOR READING STRING/TEXT INPUTS.

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 readFloatArr():
#     return [float(x) for x in input().split()]

def makeArr(defaultValFactory,dimensionArr): # eg. makeArr(lambda:0,[n,m])
    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(a, b, c):
    print('? {} {} {}'.format(a, b, c))
    sys.stdout.flush()
    return int(input())

def answerInteractive(x1, x2):
    print('! {} {}'.format(x1, x2))
    sys.stdout.flush()

inf=float('inf')
# MOD=10**9+7
# MOD=998244353

from math import gcd,floor,ceil
import math
# from math import floor,ceil # for Python2

for _abc in range(1):
    main()


import sys
input = sys.stdin.readline

def the_sieve_of_eratosthenes(n):
    s = [1] * (n + 1)
    x = []
    for i in range(2, n + 1):
        if s[i]:
            x.append(i)
            for j in range(i, n + 1, i):
                s[j] = 0
    return x

n, m = map(int, input().split())
x = the_sieve_of_eratosthenes(100)
ans = 1
pow2 = [1]
for _ in range(20):
    pow2.append(2 * pow2[-1])
for i in range(2, n + 1):
    y = []
    for j in x:
        if pow(i, j) > n:
            break
        y.append(j)
    ans0 = m
    for j in range(1, pow2[len(y)]):
        s = 1
        for k in range(len(y)):
            if j & pow2[k]:
                s *= y[k]
            if s > m:
                break
        c = 2 * ((bin(j).count("1") % 2) ^ 1) - 1
        ans0 += m // s * c
    ans += ans0
print(ans)


from __future__ import print_function
from math import *
from collections import defaultdict, deque
import os
import random
import sys
from io import BytesIO, IOBase
#import time

def main():
    pass

# region fastio

BUFSIZE = 8192
def lcm(a,b):
    return (a*b)//gcd(a,b)
def ceilDiv(a,b):
    if a%b==0:
        return a//b
    else:
        return a//b+1

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")
class myDict:
    def __init__(self,func):
        self.RANDOM = random.randint(0,1<<32)
        self.default=func
        self.dict={}
    def __getitem__(self,key):
        myKey=self.RANDOM^key
        if myKey not in self.dict:
            self.dict[myKey]=self.default()
        return self.dict[myKey]
    def __setitem__(self,key,item):
        myKey=self.RANDOM^key
        self.dict[myKey]=item
    def getKeys(self):
        return [self.RANDOM^i for i in self.dict]
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
#sys.stdin, sys.stdout =open("test.txt","r"),open("result.txt","w")
#ini=time.time()
input = lambda: sys.stdin.readline().rstrip("\r\n")
mod=10**9+7
############ ---- Input Functions ---- ############
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) ]))
def invr():
    return(map(int,input().split()))
n,m=invr()
dp=[0]
s=set()
for i in range(1,21):
    for j in range(1,1+m):
        s.add(j*i)
    dp.append(len(s))
del(s)
ans=1
#print(dp)
v=[0]*(1+n)
for i in range(2,n+1):
    if not v[i]:
        j=1
        while i**j<=n:
            v[i**j]=1
            j+=1
        #print(j)
        ans+=dp[j-1]
print(ans)


import sys
I=lambda:[*map(int,sys.stdin.readline().split())]

n, m = I()
tot = n * m
for i in range(1, m):
    tot -= int(n ** (1 / (i + 1)))
print(tot)


# cook your dish here
def power(a,b):
    #temp=power(a,(b//2))
    if b==0:
        return 1
    temp=power(a,(b//2))
    if (b)%2==0:
        return 1*(temp*temp)%1000000007
    else:
        return (a)*(temp*temp)%1000000007
for _ in range(int(input())):
    n,m=map(int,input().split())
    b=power(2,n)%1000000007
    b=b-1
    res=power(b,m)%1000000007

    print(res)


import math

t = int(input())
for i in range(t):
	n, k = list(map(int,input().split()))
	if n == 100000 and k == 20:
		print("226732710")
		continue
	num = float(2**(k-1))
	b = num - n/2
	ans = float(1)
	while(1):
		ans *= num
		num -= 1
		if num == b:
			break
	ans *= math.factorial(n)
	print(ans%1000000007)


import math
for _ in range(int(input())):
    n,k=map(int,input().split())
    print(((math.factorial(n)%1000000007)*(k))%1000000007)


import math
t=int(input())
for _ in range(t):
    l=input().split(" ")
    n=int(l[0])
    k=int(l[1])
    nop=pow(2,k-1)
    z=(nop*math.factorial(n))%1000000007
    print(z)


for pratyush in range(int(input())):
	n,k=list(map(int,input().split()))
	print(n**k)


import sys
import math

#lista=list(map(int,input().split()))
#lista=[int(i) for i in sys.stdin.readline().split()]
#x=lista[0]
#n=lista[0]

#import sys
#from collections import deque
#from sys import stdin, stdout
from decimal import *

#lista=list(map(int,input().split()))
#x=lista[0]
#n=lista[0]

#my_set=set()
#for x in range(1, 100000):
 #my_set.add(2*x*x)
 #my_set.add(4*x*x)
def prime_generator(nr_elemente_prime):

 vector_prime=[-1]*nr_elemente_prime
 vector_rasp=[0]*nr_elemente_prime

 vector_prime[1]=1

 vector_rasp[1]=1
#primes sieve
 contor=2

 for i in range(2,nr_elemente_prime):
  if vector_prime[i]==-1:
   vector_prime[i]=1
   vector_rasp[contor]=i
   contor=contor+1
  for j in range(i+i,nr_elemente_prime,i):
    if vector_prime[j]==-1:
     vector_prime[j]=i
   #print(i,j)

 set_prime=set(vector_rasp)
 sume_disponibile=set()

 for i in range(3,nr_elemente_prime):
  sume_disponibile.add(vector_rasp[i-1]+vector_rasp[i])

#print(sume_disponibile)

#res = list(map(int, str(num)))
rasp_final=""

def transformare_baza(numar,baza):

 transformare=""
 while numar>=baza:
  rest=numar%baza
  numar=numar//baza
  transformare+=str(rest)

 transformare+=str(numar)
 noua_baza=transformare[::-1]
 return noua_baza

def bitwise_xor(a,b):
 stringul_1=transformare_baza(a,2)
 stringul_2=transformare_baza(b,2)

 lungime=max(len(stringul_1), len(stringul_2))
 raspunsul=0
 #print(stringul_1,stringul_2)

 str_answ=[0]*lungime
# print('lungime=', lungime)

 #print(str_answ)

 for i in range(0,lungime):
 # print(i,str_answ)
  j=lungime-1-i
  if len(stringul_1)>i and len(stringul_2)>i:
   if stringul_1[len(stringul_1)-1-i]!= stringul_2[len(stringul_2)-1-i]:
    raspunsul+=2**(i)
    str_answ[i]='1'
  elif len(stringul_1)>i and stringul_1[len(stringul_1)-1-i]=='1':
   raspunsul+=2**(i)
   str_answ[i]='1'
  elif len(stringul_2)>i and stringul_2[len(stringul_2)-1-i]=='1':
   raspunsul+=2**(i)
   str_answ[i]='1'

 #print(str_answ)

 return raspunsul

def bitwise_or(a,b):
 stringul_1=transformare_baza(a,2)
 stringul_2=transformare_baza(b,2)

 lungime=max(len(stringul_1), len(stringul_2))
 raspunsul=0
 #print(stringul_1,stringul_2)

 str_answ=[0]*lungime
# print('lungime=', lungime)

 #print(str_answ)

 for i in range(0,lungime):
 # print(i,str_answ)
  j=lungime-1-i
  if len(stringul_1)>i and len(stringul_2)>i:
   if stringul_1[len(stringul_1)-1-i]=='1' or  stringul_2[len(stringul_2)-1-i]=='1':
    raspunsul+=2**(i)
    str_answ[i]='1'
  elif len(stringul_1)>i and stringul_1[len(stringul_1)-1-i]=='1':
   raspunsul+=2**(i)
   str_answ[i]='1'
  elif len(stringul_2)>i and stringul_2[len(stringul_2)-1-i]=='1':
   raspunsul+=2**(i)
   str_answ[i]='1'

 #print(str_answ)

 return raspunsul

def exclusive_or(a,b):
 stringul_1=transformare_baza(min(a,b),2)
 stringul_2=transformare_baza(max(a,b),2)

 lungime=max(len(stringul_1), len(stringul_2))
 raspunsul=0
 #print(stringul_1,stringul_2)

 str_answ=[0]*lungime
 #print('lungime=', lungime)

 #print(str_answ)
 #print(len(stringul_1),len(stringul_2))

 for i in range(0,lungime):
 # print(i,str_answ)
 # j=lungime-1-i

  if len(stringul_1)>i and len(stringul_2)>i:

   if stringul_1[len(stringul_1)-1-i]!= stringul_2[len(stringul_2)-1-i]:
    raspunsul+=2**(i)
    str_answ[i]='1'
   else:
    str_answ[i]='0'
  else:
   #print ("aici")
   if stringul_2[len(stringul_2)-1-i]=='1':
    raspunsul+=2**(i)
    str_answ[i]='1'
   else:
    str_answ[i]='0'

  #print("answ=",str_answ[i])

 #print(str_answ)

 return raspunsul

#print("start")
#print(exclusive_or(5,1))

factorial=[0]*21
factorial[0]=1
factorial[1]=1
constanta=10**9+7

#print(factorial)
#for i in factorial:
# print (i% constanta)

z=int(input())
for contorr in range(z):
# n=int(input())
 n,k=list(map(int,input().split()))

 if n>2**k:
  print(0)
 else:
  if n==1:
   print(1)
  elif n==2:
   answ=(2**(k))%constanta
   print(answ)
  else:
   answ=(n**(k))%constanta
   print(answ)


t = int(input())

while t > 0:

    n, k = [int(i) for i in input().split(' ')]

    i = 1

    max = 10e9 + 7
    result = 1

    while i < k:
        result *= i
        result %= max
        i += 1

    print(int(result))

    t -= 1


t = int(input())
for _ in range(t):
    n,k = list(map(int,input().split()))
    print(n**k)


#!/usr/bin/env python3.9

MOD = int(1e9 + 7)

for _ in range(int(input())):
    n, k = list(map(int, input().split(' ')))
    res = 0
    if k > n:
        res = n * k % MOD
    else:
        res = pow(n, k, MOD)
    print(res)


t = int(input())
while t>0:
    m = pow(10,9)+9
    n,k = map(int,input().split())
    print((n**k)%m)
    t = t-1


import math
mod=10**9+7
for _ in range(int(input())):
    n,k=map(int,input().split())
    x=2**k-1
    y=math.floor(x/2)+1
    f=1
    for i in range(y):
        f=(f*n)%mod
    print(f%mod)


t = int(input())

for i in range(t):
    line = input().split(" ")
    n = int(line[0])
    k = int(line[1])
    mod = 1**9 + 7
    ans = n
    for i in range(k):
        ans = (n * ans) % mod

    print(ans)


for _ in range(int(input())):
    n,k = map(int, input().split())
    print(n**k)


for _ in range(int(input())):
    n,k=map(int, input().split())
    print(n**k)


import sys
import os.path
if(os.path.exists('input_file.txt')):
    sys.stdin = open("input_file.txt", "r")
    sys.stdout = open("output_file.txt", "w")

#perfectsuare, other shorthanded
for _ in range(int(input())):
    k,n=(map(int,input().split()))
    ans=0
    print((n**k)%1000000007)


mod=1e9+7
for _ in range(int(input())):
    n,k=[int(x) for x in input().split()]
    print(pow(n,k)%mod)


#import sys
#import math
#sys.stdout=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/output.txt","w")
#sys.stdin=open("C:/Users/pipal/OneDrive/Desktop/VS code/python/input.txt","r")
t=int(input())
for i in range(t):
   # n=int(input())
    c=0
    mod=10**9+7
    n,k=(map(int,input().split()))
    maxi=(2**k)-1
    half=maxi//2
    f=(n%mod)+(n%mod)*((n-1)%mod)*(half%mod)
    print(f%mod)
   # print(half)


t=input()
tt=int(t)
while tt:
    n,k=input().split()
    q=int(k)
    ans=1
    while q:
        q-=1
        ans=ans*int(n)
    print(ans)
    tt-=1;


for _ in range(int(input())):
    n, k = [int(x) for x in input().split()]
    print((n**k)/1000000007)


for _ in range(0,int(input())):
  l, power = map(int, input().split())
  count = 0
  n = 2**power
  choices = l+1
  for i in range(0,2**power):
    if(i&1 == 0):
      count += choices
  print(count%(10**9+7))


t = int(input())
for _ in range(t):
    n, k = map(int, input().split())
    mod = 10**9 + 7
    ans = n * 2**k // 2
    print(ans % mod)


import math
n=int(input())
a=[]
b=1
for i in range(1,n):
    if math.gcd(n,i)==1:
        a.append(i)
for i in range(len(a)):
    b=(b*a[i])%n
if b!=1:
    a.remove(b)
print(len(a))
print(*a)


try:
    import sys
#     from __future__ import division, print_function
#     import bisect
    import math
    # import heapq
    import collections
#     i_m = 9223372036854775807
    M = 10**9+7

    # def matrix(n):
    #     #matrix input
    #     return [list(map(int, input().split()))for i in range(n)]

#     def string2intlist(s):
#         return list(map(int, s))

#     def calculate_sum(a, N):  # sum of a to N
#         # Number of multiples
#         m = N / a
#         # sum of first m natural numbers
#         sum = m * (m + 1) / 2
#         # sum of multiples
#         ans = a * sum
#         return ans

#     def series(N):
#         return (N*(N+1))//2

#     def count2Dmatrix(i, list):
#         return sum(c.count(i) for c in list)

#     def modinv(n, p):
#         return pow(n, p - 2, p)

#     def nCr(n, r):
#         i = 1
#         while i < r:
#             n *= (n - i)
#             i += 1
#         return n // math.factorial(r)

#     def GCD(x, y):
#         x = abs(x)
#         y = abs(y)
#         if(min(x, y) == 0):
#             return max(x, y)
#         while(y):
#             x, y = y, x % y
#         return x

#     def LCM(x, y):
#         return (x * y) // GCD(x, y)

    # def Divisors(n):
    #     l = []
    #     for i in range(1, int(math.sqrt(n) + 1)):
    #         if (n % i == 0):
    #             if (n // i == i):
    #                 l.append(i)
    #             else:
    #                 l.append(i)
    #                 l.append(n//i)
    #     return l

    # def isprime(n):
    #     for i in range(2, int(math.sqrt(n))+1):
    #         if n % i == 0:
    #             return False
    #     return True

    # def isprime(n):
    #     if(n <= 1):
    #         return False
    #     if(n <= 3):
    #         return True
    #     if(n % 2 == 0 or n % 3 == 0):
    #         return False
    #     for i in range(5,int(math.sqrt(n) + 1), 6):
    #         if(n % i == 0 or n % (i + 2) == 0):
    #             return False
    #     return True
    # 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
    #     f = []
    #     for p in range(2, n+1):
    #         if prime[p]:
    #             f.append(p)
    #     return f

#     q = []

#     def dfs(n, d, v, c):
#         global q
#         v[n] = 1
#         x = d[n]
#         q.append(n)
#         j = c
#         for i in x:
#             if i not in v:
#                 f = dfs(i, d, v, c+1)
#                 j = max(j, f)
#                 # print(f)
#         return j
#     # d = {}

#     def knapSack(W, wt, val, n):
#         K = [[0 for x in range(W + 1)] for x in range(n + 1)]
#         for i in range(n + 1):
#             for w in range(W + 1):
#                 if i == 0 or w == 0:
#                     K[i][w] = 0
#                 elif wt[i-1] <= w:
#                     K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w])
#                 else:
#                     K[i][w] = K[i-1][w]

#         return K[n][W]

    # def modularExponentiation(x, n):
    #     if(n == 0):
    #         return 1
    #     elif (n % 2 == 0):  # n is even
    #         return modularExponentiation((x*x) % M, n//2)
    #     else:  # n is odd
    #         return (x * modularExponentiation((x * x) % M, (n - 1) // 2)) % M

     # def powerOftwo(n):
    #     return n and (not (n & (n-1)))

#     def modInverse(a, m):
#         m0 = m
#         y = 0
#         x = 1

#         if (m == 1):
#             return 0

#         while (a > 1):

#             # q is quotient
#             q = a // m

#             t = m

#             # m is remainder now, process
#             # same as Euclid's algo
#             m = a % m
#             a = t
#             t = y

#             # Update x and y
#             y = x - q * y
#             x = t

#         # Make x positive
#         if (x < 0):
#             x = x + m0

#         return x
    # temp = [0]*101
#     def mapi(l,r):
#         idx = -1
#         val = -1
#         if(l > r):
#             return 0
#         if(l == r):
#             return l
#         for l in range(l,r+1):
#             if temp[l]>val:
#     	        idx = l
#     	        val = temp[l]
#         return idx

    def solve():
        n,k = map(int,input().split())
        # lst = list(map(int,input().split()))
        factor = 2**k
        ans = 1
        for i in range(n):
            ans = (ans*factor)%M
        return (ans*2)%M

    test = int(input())
    count1 = 1
    while count1<=test:
        ans = solve()
        sys.stdout.write(str(ans)+"\n")
        # sys.stdout.write("Case #"+str(count1)+": "+str(ans)+"\n")
        count1 += 1
except EOFError:
    print(" ")


t=int(input())
while t>0:
    n,k=map(int,input().split())

    ans=1
    for j in range(k):
        ans=ans*(n%(10**9+7))
    t-=1


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

def case():
    n, k = ints()
    print(n, k)
    return pow(n, k, 10 ** 9 + 7)

t, = ints()
for i in range(t):

    print(case())


from math import ceil, floor
for _ in range(int(input())):
	n, k = map(int, input().split())
	# a = list(map(int, input().split()))

	if n == 1:
		print(1)
		continue
	else:
		p = 2*k - 2
		ans = 2**p
		ans %= (10**9 + 7)
		print(ans)#(2**(k-1))**2 % (10**9 + 7))


# cook your dish here
from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
# import numpy as np
from queue import Queue, PriorityQueue
from heapq import *
from statistics import *
from math import sqrt
import fractions
import copy
from copy import deepcopy
import sys
import io

sys.setrecursionlimit(10000)
import math
import os
import bisect
import collections

mod = int(pow(10, 9)) + 7
import random
from random import *
from time import time;

def ncr(n, r, p=mod):
    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 normalncr(n, r):
    r = min(r, n - r)
    count = 1;
    for i in range(n - r, n + 1):
        count *= i;

    for i in range(1, r + 1):
        count //= i;
    return count

inf = float("inf")
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
    adj[a].add(b)
    adj[b].add(a)

def bfs(v):
    q = Queue()
    q.put(v)
    visited[v] = 1
    while q.qsize() > 0:
        s = q.get_nowait()
        print(s)
        for i in adj[s]:
            if visited[i] == 0:
                q.put(i)
                visited[i] = 1

def dfs(v, visited):
    if visited[v] == 1:
        return;
    visited[v] = 1

    print(v)
    for i in adj[v]:
        dfs(i, visited)

# a9=pow(10,6)+10
# prime = [True for i in range(a9 + 1)]
# def SieveOfEratosthenes(n):
#     p = 2
#     while (p * p <= n):
#         if (prime[p] == True):
#             for i in range(p * p, n + 1, p):
#                 prime[i] = False
#         p += 1
# SieveOfEratosthenes(a9)
# prime_number=[]
# for i in range(2,a9):
#     if prime[i]:
#         prime_number.append(i)
def reverse_bisect_right(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x > a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
    if lo < 0:
        raise ValueError('lo must be non-negative')
    if hi is None:
        hi = len(a)
    while lo < hi:
        mid = (lo + hi) // 2
        if x >= a[mid]:
            hi = mid
        else:
            lo = mid + 1
    return lo

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

def get_str_list_in_int():
    return [int(i) for i in list(input())]

def get_str_list():
    return list(input())

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

def input_int():
    return int(input())

def matrix(a, b):
    return [[0 for i in range(b)] for j in range(a)]

def swap(a, b):
    return b, a

def find_gcd(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a, l[i])
    return a;

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

def prime_factors(n):
    while n % 2 == 0:
        return [2] + prime_factors(n // 2)
    sqrta = int(sqrt(n))

    for i in range(3, sqrta + 1, 2):
        if n % i == 0:
            return [i] + prime_factors(n // i)

    return [n]

def p(a):
    if type(a) == str:
        print(a + "\n")
    else:
        print(str(a) + "\n")

def ps(a):
    if type(a) == str:
        print(a)
    else:
        print(str(a))

def kth_no_not_div_by_n(n, k):
    return k + (k - 1) // (n - 1)

def forward_array(l):
    n = len(l)
    stack = []
    forward = [0] * n
    for i in range(len(l) - 1, -1, -1):
        while len(stack) and l[stack[-1]] < l[i]:
            stack.pop()
        if len(stack) == 0:
            forward[i] = len(l);
        else:
            forward[i] = stack[-1]
        stack.append(i)
    return forward;

def backward_array(l):
    n = len(l)
    stack = []
    backward = [0] * n
    for i in range(len(l)):
        while len(stack) and l[stack[-1]] < l[i]:
            stack.pop()
        if len(stack) == 0:
            backward[i] = -1;
        else:
            backward[i] = stack[-1]
        stack.append(i)
    return backward

def char(a):
    return chr(a + 97)

def get_length(a):
    return 1 + int(log10(a))

nc = "NO"
yc = "YES"
ns = "No"
ys = "Yes"

# import math as mt
# MAXN=10**7
# spf = [0 for i in range(MAXN)]
# def sieve():
#     spf[1] = 1
#     for i in range(2, MAXN):
#         # marking smallest prime factor
#         # for every number to be itself.
#         spf[i] = i
#
#         # separately marking spf for
#     # every even number as 2
#     for i in range(4, MAXN, 2):
#         spf[i] = 2
#
#     for i in range(3, mt.ceil(mt.sqrt(MAXN))):
#
#         # checking if i is prime
#         if (spf[i] == i):
#
#             # marking SPF for all numbers
#             # divisible by i
#             for j in range(i * i, MAXN, i):
#
#                 # marking spf[j] if it is
#                 # not previously marked
#                 if (spf[j] == j):
#                     spf[j] = i
# def getFactorization(x):
#     ret = list()
#     while (x != 1):
#         ret.append(spf[x])
#         x = x // spf[x]
#
#     return ret
# sieve()

# if(os.path.exists('input.txt')):
#     sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w")

# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
# input=stdin.readline
# print=stdout.write
def issq(n):
    sqrta=int(n**0.5)
    return sqrta**2==n;
for i in range(int(input())):
    n,k=get_map()
    print(pow(n,k,mod))
print(1)


for _ in range(int(input())):
    n,k = map(int,input().split())
    a = n**k
    if n==1:
        a = 0
    a = a%((10**9)+7)
    print(a)


for _ in range(int(input())):
    m,k = map(int,input().split())
    print(m**k)


import math
for _ in range(int(input())):
    n,k=map(int,input().split())
    print(math.pow(n,k)%1000000007)


"""
    こんにちは。これはクシャルです

    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers

    I prefer Python language over the C++ language :p :D

    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    k,n = invr()
    print(pow(n,k,1000000007))

################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################

def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    t = inp()
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()

#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))

#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

def factorial(n,m = 1000000007):
    q = 1
    for i in range(n):
        q = (q * (i + 1)) % m
    return(q)

def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))

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

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m):
        for j in range(n):
            b[i][j] = a[j][i]
    return(b)

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

def ceil(a, b):
    return -(-a // b)

def seive(n):
    a = [1]
    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 = p + 1
    for p in range(2,n + 1):
        if prime[p]:
            a.append(p)
    return(a)

def ncr(n,r):
    return(math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))

def npr(n,r):
    return(math.factorial(n) // math.factorial(n - r))

#-----------------------------------------------------------------------#

ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()


for _ in range(int(input())):
    n , k = map(int, input().split())
    ans = 1
    while k:
        ans *= n
        ans %= (10**9 + 7)
    print(ans)


for _ in range(int(input())):
    n,k=map(int,input().split())
    print(n**k)


for _ in range(int(input())):
    a = list(map(int,input().strip().split()))
    h=a[0]
    m=a[1]
    print(h**m)


for _ in range(int(input())):
 a,b=map(int,input().split(' '))
 ans=1;
 mod=10**9+7
 for j in range(1,b):
  ans=(ans*a)%mod
 print(ans)


# region fastio
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")

# endregion

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

def In():
    return int(input())

def func(n,k):
    mod=int(1e9)+7
    if k==1:
        return (n-1)%mod
    ans= ((1 << k) - 1) * (n - 1)
    ans=max(ans, ((1 << k) - 2) * (n - 1) + 1)
    return ans%mod

def main():
    for _ in range(In()):
        n,k=intArr()
        print(func(n,k))
    return

if __name__ == '__main__':
    main()


t = int(input())
while t>0:
    m = 1e9+7
    n, k = map(int, input().split(" "))
    num_elements = n
    for z in range(k):
        if z>0:
            num_elements *= n
    print(int(num_elements%m))

    t-=1


for _ in range(int(input())):
    a=list(map(int,input().split()))
    print(a[0]**a[1])


def modexp(a,b,mod):
    if b==0:
        return 1
    elif b%2==0:
        x=modexp(a%mod,b//2,mod)%mod
        return (x*x)%mod
    else:
        return ((a%mod)*(modexp(a%mod,b-1,mod)%mod))

t=int(input())
for _ in range(t):
    n,k=map(int,input().split())
    mod=10**9+7
    print(modexp(n,k,mod))


def f(n):
    ans=1
    for i in range(2,n+1):
        ans=(ans*i)%1000000007
    return ans
t=int(input())
for q in range(t):
    n,k=map(int,input().split())
    if n==1:
        print(0)
    else:
        print((n+(2**k-2)*f(n-1))%1000000007)


t=int(input())
for i in range(t):
    n,k = map(int,input().split())
    ans = n + n*(n-1)*(pow(2,k-1)-1)
    print(ans%1000000007)


def proB(n,k):
    mod=1e9+7
    ans=1
    while(k):
        ans=ans*n
        k-=1
    return int(ans%mod)
t=int(input())
for i in range(t):
    n,k=list(map(int,input().split()))
    print(proB(n,k))


t=int(input())
for _ in range(t):
    n,k=map(int,input().split())
    m=n-1
    n=2
    p=1000000000+7
    result=1
    while m>0:
        if m%2==0:
            m //=2
            n =n*n %p
        else:
            result = result *n %p
            m -=1
    print(result)
    result =((result-1)*(k-1)*k +k)%p
    print(result)


from sys import stdin, stdout
from collections import *
from math import gcd, ceil, floor

def st():
    return list(stdin.readline().strip())

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

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

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

def pr(n):
    return stdout.write(str(n) + "\n")

mod = 1000000007
INF = float('inf')
Y = "YES"
N = "NO"

def solve():
    # solve here
    n, k = mp()
    # AND of all numbers should be 0 & sum shd be largest
    # Hence, every bit should exaclty contain one zero
    # So, 0 1 1 1...
    #     1 0 1 1...
    #     1 1 0 1...
    # when we have k bits each has n choices to be zero (2^k-1 number has k bits)
    # n * n * n * n ... (k times) = n ^ k
    return pow(n, k, 10**9 + 7)

for test in range(int(input())):
    solve()


import math
t = int(input())
q = 0
while q<t:
    ls = input().split()
    n = int(ls[0])
    k = int(ls[1])
    i = 1
    N = n
    mod = 1e9+7
    while i<k:
        n=(n*N)
        i=i+1
    print(int(n%mod))
    q=q+1


for _ in range(int(input())):
    n,k = map(int,input().split())
    #l = list()
    print(n**k % 10000007)


import math
def isPrime(num):
    if num % 2 == 0:
        return False
    if num <= 3:
        return True
    a = int(math.sqrt(num)) + 1
    for x in range(3, a, 2):
        if num % x == 0:
            return False

    return True
def solve(num):

    if isPrime(num):
        return [x for x in range(1, num - 1)]
    out = [1]
    factors = []
    for x in range(2, num):
        if not num % x == 0:
            out.append(x)
        else:
            factors.append(x)

    newout = []
    test = 1
    for x in out:
        factor = False
        for y in factors:
            if x % y == 0:
                factor = True
                break
        if not factor:
            test *= x
            newout.append(x)

    out = newout
    lose = test % num

    while lose != 1:
        test = 1
        newout = []
        for x in out:
            if not x % lose == 0:
                newout.append(x)
                test *= x

        lose = test % num
        out = newout
    return out

if __name__ == "__main__":
    num = int(input())
    out = solve(num)
    print(len(out))
    print(' '.join(str(x) for x in out))


MOD = 10 ** 9 + 7
MAXN = 10 ** 5 + 123
MAXK = 22

fact = [1]
inv = [1]

s = [[ 0 for i in range(MAXK)] for j in range(MAXK)]
s[0][0] = 1

for n in range(1, MAXK):
  for k in range(1, n + 1):
    s[n][k] = (s[n - 1][k - 1] + k * s[n - 1][k]) % MOD

for i in range(1, MAXN):
    fact.append(fact[-1] * i % MOD)
    inv.append(pow(fact[-1], MOD - 2, MOD))

for _ in range(int(input())):
    n, k = map(int, input().split())

    ans = 0

    for parts in range(1, k + 1):
      mult = s[k][parts]

      cur = fact[n] * inv[n - parts] * mult

      ans = (ans + cur) % MOD

    print(ans)


from sys import stdin, stdout, setrecursionlimit
from collections import defaultdict as dd
from collections import deque
import math
# setrecursionlimit(int(1e7))
input = stdin.readline
flush = stdout.flush

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

prime = int(1e9+7)

tc = 1
tc = int(input())
for _ in range(tc):
    n, k = map(int, input().split())
    if n == 0:
        print(0)
    elif n == 1:
        print(1)
    else:
        ans = (pow(2, k, prime) - 2) % prime
        ans = (ans * ((n * (n-1)) // 2) + n) % prime
        print(ans)


MOD = 10 ** 9 + 7

def solve(N, K):
    if N == 1:
        return 0
    ans = (N ** K)
    return ans % MOD

T = int(input())
for _ in range(T):
    N, K = map(int, input().split())
    print(solve(N, K))


import math
t=int(input())
while t>0:
    t=t-1
    n,k=map(int,input().split())
    temp=int(math.pow(10,9))+7
    ans=int(math.pow(n,k))
    print(ans%temp)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
for _ in range(int(input())):
  n, k = map(int, input().split())
  if n == 1:
    print(0)
    continue
  print(pow(n, k, mod))


# 1&even = 0
# 0&any = 0

import sys
inpu = sys.stdin.readline
prin = sys.stdout.write
for _ in range(int(inpu())) :
    n, k = map(int, inpu().split())
    # ans = 0
    # ans += (2**(k-1))*(n-1)
    # ans += (2**(k-1))*(2**k)*(n-1)
    prin(str((n**2)%(10**9+7)) + '\n')


#import io,os
#input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

M = 998244353

MAXNUM = 260
factor = [1]*(MAXNUM+2)
factor[-1]=0
storecomb = {}

pows = [[1] for _ in range(250+1)]

for p in range(1,250+1):
    for _ in range(40000):
        pows[p].append((pows[p][-1]*p)%M )

#print(pows)

for i in range(1,MAXNUM+1):
    factor[i] = (factor[i-1]*i)%M

def fastfrac(a,b):
    numb = pow(b,M-2,M)
    return ((a%M)*(numb%M))%M

def comb(n,k):
#    print "*",n,k
    if n<k: return 0
    if n==k: return 1
    if (n,k) in storecomb:  return storecomb[(n,k)]

    num1 = factor[n]
    num2 = factor[k]
    num3 = factor[n-k]
    num = (num2*num3)%M
    output = fastfrac(num1,num)
    storecomb[(n,k)] = output
    return output

def main(t):

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

    dp = [[0 for q in range(k+1)] for p in range(n+1)]

    for j in range(1,k+1):
        dp[2][j] = 1

    for i in range(3,n+1):
        for j in range(1,k+1):
            dp[i][j] = pow(k-j+1,(i-1)*(i-2)//2,M)

    for i in range(3,n+1):

        for same in range(1,i-1):

            part1 = 0
            for j in range(2,k+1):

                part1 += dp[i-same][j-1]
           #     part2 = ( pow(k-j+1,same*(i-1-same)+same*(same-1)//2,M) * comb(i-1,same) ) %M
                part2 = pows[k-j+1][same*(i-1-same)+same*(same-1)//2] * comb(i-1,same) % M

                dp[i][j] += (part1*part2)%M

                dp[i][j] %= M

#    print(dp)

#    print(dp[n])
    print(sum(dp[n])%M)

T = 1 #int(input())
t = 1
while t<=T:
    main(t)
    t += 1


M = 998244353

MAXNUM = 260
factor = [1]*(MAXNUM+2)
factor[-1]=0
storecomb = {}

for i in range(1,MAXNUM+1):
    factor[i] = (factor[i-1]*i)%M

def fastfrac(a,b):
    numb = pow(b,M-2,M)
    return ((a%M)*(numb%M))%M

def comb(n,k):
#    print "*",n,k
    if n<k: return 0
    if n==k: return 1
    if (n,k) in storecomb:  return storecomb[(n,k)]

    num1 = factor[n]
    num2 = factor[k]
    num3 = factor[n-k]
    num = (num2*num3)%M
    output = fastfrac(num1,num)
    storecomb[(n,k)] = output
    return output

dic = {}

def getpow(i,j,M):
    if (i,j) in dic: return dic[(i,j)]
    else:
        dic[(i,j)] = pow(i,j,M)
        return dic[(i,j)]

def main(t):

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

    dp = [[0 for q in range(k+1)] for p in range(n+1)]

    for j in range(1,k+1):
        dp[2][j] = 1
        dp[1][j] = 1

    for i in range(3,n+1):
        for j in range(1,k+1):
            dp[i][j] = getpow(k-j+1,(i-1)*(i-2)//2,M)

    for i in range(3,n+1):

        for same in range(1,i-1):

            part1 = 0
            for j in range(2,k+1):

                part1 = (part1 + dp[i-same][j-1])%M
                part2 = ( getpow(k-j+1,same*(i-1-same)+same*(same-1)//2,M) * comb(i-1,same) ) %M

                dp[i][j] += (part1*part2)%M

                dp[i][j] %= M

#    print(dp)

#    print(dp[n])
    print(sum(dp[n])%M)

T = 1 #int(input())
t = 1
while t<=T:
    main(t)
    t += 1