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

mod = 10**9+7



def power(a, n, mod):

    bi=str(format(n,"b")) #2進数

    res=1

    for i in range(len(bi)):

        res=(res*res) %mod

        if bi[i]=="1":

            res=(res*a) %mod

    return res



D = [0]*(k+1)

ans = 0

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

    a = k//i

    d = power(a, n, mod)

    j = 1

    while i*j <= k:

        d -= D[i*j]

        j += 1

    D[i] = d

    ans += (d*i)%mod



print((ans%mod))
n, k = list(map(int, input().split()))



mod = 10**9+7



def power(a, n, mod):

  bi=str(format(n,"b")) #2進数

  res=1

  for i in range(len(bi)):

    res=(res*res) %mod

    if bi[i]=="1":

      res=(res*a) %mod

  return res





X = [0]*(k+1)

ans = 0

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

    temp = power(k//i, n, mod)

    j = i+i

    while j <= k:

        temp -= X[j]

        j += i

    X[i] = temp

    ans += (temp*i)%mod

print((ans%mod))

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


def power(a, n, mod):
    bi = str(format(n, "b"))  # 2進数
    res = 1
    for i in range(len(bi)):
        res = (res * res) % mod
        if bi[i] == "1":
            res = (res * a) % mod
    return res


D = [0] * (k + 1)
ans = 0
for i in reversed(list(range(1, k + 1))):
    a = k // i
    d = power(a, n, mod)
    j = 1
    while i * j <= k:
        d -= D[i * j]
        j += 1
    D[i] = d
    ans += (d * i) % mod
print((ans % mod))

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


def power(a, n, mod):
    bi = str(format(n, "b"))  # 2進数
    res = 1
    for i in range(len(bi)):
        res = (res * res) % mod
        if bi[i] == "1":
            res = (res * a) % mod
    return res


X = [0] * (k + 1)
ans = 0
for i in reversed(list(range(1, k + 1))):
    temp = power(k // i, n, mod)
    j = i + i
    while j <= k:
        temp -= X[j]
        j += i
    X[i] = temp
    ans += (temp * i) % mod
print((ans % mod))

-D = [0] * (k + 1) +X = [0] * (k + 1) -    a = k // i -    d = power(a, n, mod) -    j = 1 -    while i * j <= k: -        d -= D[i * j] -        j += 1 -    D[i] = d -    ans += (d * i) % mod +    temp = power(k // i, n, mod) +    j = i + i +    while j <= k: +        temp -= X[j] +        j += i +    X[i] = temp +    ans += (temp * i) % mod