M=10**9+7

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

d=[0]*-~k

a=0

for i in range(k,0,-1):

    t=c=0

    for j in range(i,k+1,i):

        c+=1

        t+=d[j]

    d[i]=pow(c,n,M)-t

    a=(a+i*d[i])%M

print(a)
M=10**9+7

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

d=[0]*-~k

a=0

for i in range(k,0,-1):d[i]=pow(k//i,n,M)-sum(d[::i]);a+=i*d[i]

print((a%M))
M = 10**9 + 7
n, k = list(map(int, input().split()))
d = [0] * -~k
a = 0
for i in range(k, 0, -1):
    t = c = 0
    for j in range(i, k + 1, i):
        c += 1
        t += d[j]
    d[i] = pow(c, n, M) - t
    a = (a + i * d[i]) % M
print(a)

M = 10**9 + 7
n, k = list(map(int, input().split()))
d = [0] * -~k
a = 0
for i in range(k, 0, -1):
    d[i] = pow(k // i, n, M) - sum(d[::i])
    a += i * d[i]
print((a % M))

-    t = c = 0 -    for j in range(i, k + 1, i): -        c += 1 -        t += d[j] -    d[i] = pow(c, n, M) - t -    a = (a + i * d[i]) % M -print(a) +    d[i] = pow(k // i, n, M) - sum(d[::i]) +    a += i * d[i] +print((a % M))