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

mod = 10 ** 9 + 7



cnt = [0] * (k + 1)



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

    c = pow(k // i, n, mod)

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

        if i * j > k:

            break

        c -= cnt[i * j]

        c %= mod



    cnt[i] = c



ans = 0

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

    ans += i * cnt[i]

    ans %= mod



print(ans)

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

mod = 10 ** 9 + 7



cnt = [0] * (k + 1)



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

    c = pow(k // i, n, mod)

    c -= sum(cnt[i * 2::i])

    c %= mod

    cnt[i] = c



ans = 0

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

    ans += i * cnt[i]

    ans %= mod



print(ans)

n, k = list(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * (k + 1)
for i in range(k, 0, -1):
    c = pow(k // i, n, mod)
    for j in range(2, k + 1):
        if i * j > k:
            break
        c -= cnt[i * j]
        c %= mod
    cnt[i] = c
ans = 0
for i in range(1, k + 1):
    ans += i * cnt[i]
    ans %= mod
print(ans)

n, k = list(map(int, input().split()))
mod = 10**9 + 7
cnt = [0] * (k + 1)
for i in range(k, 0, -1):
    c = pow(k // i, n, mod)
    c -= sum(cnt[i * 2 :: i])
    c %= mod
    cnt[i] = c
ans = 0
for i in range(1, k + 1):
    ans += i * cnt[i]
    ans %= mod
print(ans)

-    for j in range(2, k + 1): -        if i * j > k: -            break -        c -= cnt[i * j] -        c %= mod +    c -= sum(cnt[i * 2 :: i]) +    c %= mod