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

MOD = 10**9 + 7



M = int(K ** .5)

f_l = [0] * (M+1)  # f(k)

f_h = [0] * (M+1)  # f(K//d)



def f(k):

  return f_l[k] if k <= M else f_h[K//k]



def compute_f(k):

  x = pow(k, N, MOD)

  sq = int(k ** .5)

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

    n = k // d

    if n <= sq:

      break

    x -= f(n)

  for n in range(1, sq+1):

    cnt = k//n - k//(n+1)

    x -= f_l[n] * cnt

  return x



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

  f_l[k] = compute_f(k)



for d in range(M, 0, -1):

  f_h[d] = compute_f(K//d)



answer = 0



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

  low_d = K // (k+1) + 1

  high_d = K // k

  items = high_d - low_d + 1

  coef = (low_d + high_d) * items // 2

  answer += coef * f_l[k]

  

for d in range(1, M+1):

  if K // d <= M:

    break

  answer += d * f_h[d]



answer %= MOD

print(answer)
MOD = 10**9 + 7

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



def phi_table(N):

    phi = list(range(N + 1))

    for p in range(2, N + 1):

        if phi[p] == p:

            for n in range(N // p, 0, -1):

                phi[p * n] -= phi[n]

    return phi





L = int(N ** .66)

H = int(N // (L + 1))

phi = phi_table(L)



# f(n) = \sum_{i=1}^n phi(i)



f_l = phi.copy()

for n in range(L):

    f_l[n + 1] += f_l[n]



f_h = [0] * (H + 1)  # f(N//d)





def f(n):

    return f_l[n] if n <= L else f_h[N // n]





def compute_f(n):

    sq = int(n ** .5)

    x = n * (n + 1) // 2

    for d in range(1, n + 1):

        m = n // d

        if m <= sq:

            break

        x -= f(m)

    for m in range(1, sq + 1):

        cnt = n // m - n // (m + 1)

        x -= f_l[m] * cnt

    return x





for d in range(H, 0, -1):

    f_h[d] = compute_f(N // d)



sq = int(N ** .5)

answer = 0

for d in range(1, N + 1):

    n = N // d

    if n <= sq:

        break

    answer += pow(n, e, MOD) * phi[d]



for n in range(1, sq + 1):

    low_d = N // (n + 1)

    high_d = N // n

    phi_sum = f(high_d) - f(low_d)

    answer += phi_sum * pow(n, e, MOD)



answer %= MOD

print(answer)

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
M = int(K**0.5)
f_l = [0] * (M + 1)  # f(k)
f_h = [0] * (M + 1)  # f(K//d)


def f(k):
    return f_l[k] if k <= M else f_h[K // k]


def compute_f(k):
    x = pow(k, N, MOD)
    sq = int(k**0.5)
    for d in range(2, k + 1):
        n = k // d
        if n <= sq:
            break
        x -= f(n)
    for n in range(1, sq + 1):
        cnt = k // n - k // (n + 1)
        x -= f_l[n] * cnt
    return x


for k in range(1, M + 1):
    f_l[k] = compute_f(k)
for d in range(M, 0, -1):
    f_h[d] = compute_f(K // d)
answer = 0
for k in range(1, M + 1):
    low_d = K // (k + 1) + 1
    high_d = K // k
    items = high_d - low_d + 1
    coef = (low_d + high_d) * items // 2
    answer += coef * f_l[k]
for d in range(1, M + 1):
    if K // d <= M:
        break
    answer += d * f_h[d]
answer %= MOD
print(answer)

MOD = 10**9 + 7
e, N = list(map(int, input().split()))


def phi_table(N):
    phi = list(range(N + 1))
    for p in range(2, N + 1):
        if phi[p] == p:
            for n in range(N // p, 0, -1):
                phi[p * n] -= phi[n]
    return phi


L = int(N**0.66)
H = int(N // (L + 1))
phi = phi_table(L)
# f(n) = \sum_{i=1}^n phi(i)
f_l = phi.copy()
for n in range(L):
    f_l[n + 1] += f_l[n]
f_h = [0] * (H + 1)  # f(N//d)


def f(n):
    return f_l[n] if n <= L else f_h[N // n]


def compute_f(n):
    sq = int(n**0.5)
    x = n * (n + 1) // 2
    for d in range(1, n + 1):
        m = n // d
        if m <= sq:
            break
        x -= f(m)
    for m in range(1, sq + 1):
        cnt = n // m - n // (m + 1)
        x -= f_l[m] * cnt
    return x


for d in range(H, 0, -1):
    f_h[d] = compute_f(N // d)
sq = int(N**0.5)
answer = 0
for d in range(1, N + 1):
    n = N // d
    if n <= sq:
        break
    answer += pow(n, e, MOD) * phi[d]
for n in range(1, sq + 1):
    low_d = N // (n + 1)
    high_d = N // n
    phi_sum = f(high_d) - f(low_d)
    answer += phi_sum * pow(n, e, MOD)
answer %= MOD
print(answer)

-N, K = list(map(int, input().split())) -M = int(K**0.5) -f_l = [0] * (M + 1)  # f(k) -f_h = [0] * (M + 1)  # f(K//d) +e, N = list(map(int, input().split())) -def f(k): -    return f_l[k] if k <= M else f_h[K // k] +def phi_table(N): +    phi = list(range(N + 1)) +    for p in range(2, N + 1): +        if phi[p] == p: +            for n in range(N // p, 0, -1): +                phi[p * n] -= phi[n] +    return phi -def compute_f(k): -    x = pow(k, N, MOD) -    sq = int(k**0.5) -    for d in range(2, k + 1): -        n = k // d -        if n <= sq: +L = int(N**0.66) +H = int(N // (L + 1)) +phi = phi_table(L) +# f(n) = \sum_{i=1}^n phi(i) +f_l = phi.copy() +for n in range(L): +    f_l[n + 1] += f_l[n] +f_h = [0] * (H + 1)  # f(N//d) + + +def f(n): +    return f_l[n] if n <= L else f_h[N // n] + + +def compute_f(n): +    sq = int(n**0.5) +    x = n * (n + 1) // 2 +    for d in range(1, n + 1): +        m = n // d +        if m <= sq: -        x -= f(n) -    for n in range(1, sq + 1): -        cnt = k // n - k // (n + 1) -        x -= f_l[n] * cnt +        x -= f(m) +    for m in range(1, sq + 1): +        cnt = n // m - n // (m + 1) +        x -= f_l[m] * cnt -for k in range(1, M + 1): -    f_l[k] = compute_f(k) -for d in range(M, 0, -1): -    f_h[d] = compute_f(K // d) +for d in range(H, 0, -1): +    f_h[d] = compute_f(N // d) +sq = int(N**0.5) -for k in range(1, M + 1): -    low_d = K // (k + 1) + 1 -    high_d = K // k -    items = high_d - low_d + 1 -    coef = (low_d + high_d) * items // 2 -    answer += coef * f_l[k] -for d in range(1, M + 1): -    if K // d <= M: +for d in range(1, N + 1): +    n = N // d +    if n <= sq: -    answer += d * f_h[d] +    answer += pow(n, e, MOD) * phi[d] +for n in range(1, sq + 1): +    low_d = N // (n + 1) +    high_d = N // n +    phi_sum = f(high_d) - f(low_d) +    answer += phi_sum * pow(n, e, MOD)