N, K = list(map(int, input().split()))



def func(n):

    r = n

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

        if i ** 2 > n:

            break



        if n % i == 0:

            r -= r // i

            while n % i == 0:

                n //= i

        

    if n > 1:

        r -= r // n

    return r





MOD = 10 ** 9 + 7

ans = 0

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

    ans += func(i) * pow(K // i, N, MOD)

print((ans % MOD))

N, K = list(map(int, input().split()))



MOD = 10 ** 9 + 7

cnt = [0] * (K + 1)

ans = 0

for x in reversed(list(range(1, K + 1))):

    cnt[x] += pow(K // x, N, MOD)

    for n in range(2, K + 1):

        if x * n > K:

            break

        cnt[x] -= cnt[x * n]

    cnt[x] %= MOD

    ans += x * cnt[x] % MOD



print((ans % MOD))

N, K = list(map(int, input().split()))


def func(n):
    r = n
    for i in range(2, n + 1):
        if i**2 > n:
            break
        if n % i == 0:
            r -= r // i
            while n % i == 0:
                n //= i
    if n > 1:
        r -= r // n
    return r


MOD = 10**9 + 7
ans = 0
for i in range(1, K + 1):
    ans += func(i) * pow(K // i, N, MOD)
print((ans % MOD))

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
cnt = [0] * (K + 1)
ans = 0
for x in reversed(list(range(1, K + 1))):
    cnt[x] += pow(K // x, N, MOD)
    for n in range(2, K + 1):
        if x * n > K:
            break
        cnt[x] -= cnt[x * n]
    cnt[x] %= MOD
    ans += x * cnt[x] % MOD
print((ans % MOD))

- - -def func(n): -    r = n -    for i in range(2, n + 1): -        if i**2 > n: +MOD = 10**9 + 7 +cnt = [0] * (K + 1) +ans = 0 +for x in reversed(list(range(1, K + 1))): +    cnt[x] += pow(K // x, N, MOD) +    for n in range(2, K + 1): +        if x * n > K: -        if n % i == 0: -            r -= r // i -            while n % i == 0: -                n //= i -    if n > 1: -        r -= r // n -    return r - - -MOD = 10**9 + 7 -ans = 0 -for i in range(1, K + 1): -    ans += func(i) * pow(K // i, N, MOD) +        cnt[x] -= cnt[x * n] +    cnt[x] %= MOD +    ans += x * cnt[x] % MOD