Consider sequences \{A_1,...,A_N\} of length N consisting of integers between 1 and K (inclusive).
There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them.
Since this sum can be enormous, print the value modulo (10^9+7).
Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.

-----Constraints-----
 - 2 \leq N \leq 10^5
 - 1 \leq K \leq 10^5
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K

-----Output-----
Print the sum of \gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).

-----Sample Input-----
3 2

-----Sample Output-----
9

\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)=1+1+1+1+1+1+1+2=9
Thus, the answer is 9.

Difficulty: interview

Starter code:

Solutions:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)



class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = [2]
        for j in range(4, m, 2):
            a[j] = False
        for i in range(3, m, 2):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False
        self.ds_memo = {}
        self.ds_memo[1] = set([1])

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d.items()

    # memo
    def divisions(self, n):
        if n in self.ds_memo:
            return self.ds_memo[n]

        for c in self.T:
            if n % c == 0:
                rs = set([c])
                for cc in self.divisions(n // c):
                    rs.add(cc)
                    rs.add(cc * c)
                self.ds_memo[n] = rs
                return rs

        rs = set([1, n])
        self.ds_memo[n] = rs
        return rs

def main():
    n,k = LI()
    pr = Prime(10**5)
    c = collections.defaultdict(int)
    for i in range(k, 0, -1):
        t = k // i
        p = (pow(t, n, mod) + c[i]) % mod
        ds = pr.divisions(i)
        for kk in ds:
            if kk == i:
                continue
            c[kk] -= p
        c[i] = p

    r = sum(k*v%mod for k,v in c.items()) % mod

    return r

print(main())





#!/usr/bin/env python
n, k = list(map(int, input().split()))
mod = 10**9+7

d = [-1 for _ in range(k+1)]
d[k] = 1 

for i in range(k-1, 0, -1):
    d[i] = pow(k//i, n, mod)
    j = 2*i 
    while j <= k:
        d[i] -= d[j]
        j += i

#print('d =', d)
ans = 0 
for i in range(1, k+1):
    ans += (i*d[i])%mod
print((ans%mod))


import sys
input=lambda :sys.stdin.readline().rstrip()

mod = 10**9+7

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

d = [0] * (k+1)
for i in range(1, k+1):
    d[i] = pow(k//i, n, mod)

for i in range(k, 0, -1):
    for j in range(2*i, k+1, i):
        d[i] -= d[j]
        d[i] %= mod
ans=0
for i in range(1, k+1):
    ans += d[i]*i
    ans %= mod

print(ans)

MOD = 10 ** 9 + 7
N, K = list(map(int, input().split()))
d = [0] * (K + 1)
for i in range(1, K + 1):
    d[i] = pow(K // i, N, MOD)
for i in reversed(list(range(1, K + 1))):
    for j in range(2 * i, K + 1, i):
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i in range(1, K + 1):
    ans += d[i] * i
    ans %= MOD
print(ans)


N, K = map(int, input().split())
numgcd = [0]*(K+1)
sumgcd = 0
mod = 10**9+7
for i in range(1, K+1)[::-1]:
    numgcd[i] = pow(K//i, N, mod)
    count = 2
    while count*i <= K:
        numgcd[i] -= numgcd[count*i]
        count += 1
    sumgcd += numgcd[i]*i
print(sumgcd%mod)

N, K = map(int, input().split())
li = [0]*(K+1)

out = 0
mod = 10**9+7

for i in range(K, 0, -1):
  li[i] = pow(K//i, N, mod) 
  for j in range(i*2, K+1, i):
    li[i] -= li[j]
  out += li[i] * i
print(out%mod)

def main():
    import sys
    input = sys.stdin.readline
    """"ここに今までのコード"""
    n, k = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    ans = 0
    baig = [0 for i in range(10 ** 5 + 1)]

    for i in range(1, k + 1):
        baig[i] = pow(k // i , n , MOD)

    for j in range(k, 0, -1):
        for jj in range(2 * j, k + 1, j):
            baig[j] -= baig[jj]
        baig[j] %= MOD
        ans += baig[j] * j
        ans %= MOD
    print((int(ans)))
def __starting_point():
    main()

__starting_point()

def pow(a, n, mod):
    ret = 1
    pw = a
    while n > 0:
        if n & 1 == 1:
            ret *= pw
            ret %= mod
        n >>= 1
        pw *= pw
        pw %= mod
    return ret


def main():
    MOD = 10 ** 9 + 7
    N, K = list(map(int, input().split(' ')))
    n_gcds = [0 for _ in range(K + 1)]
    for g in range(K, 0, -1):
        v = pow(K // g, N, MOD)
        gg = g
        while gg + g <= K:
            gg += g
            v -= n_gcds[gg]
            v %= MOD
        n_gcds[g] = v
    ans = 0
    for g, n in enumerate(n_gcds):
        ans += g * n
        ans %= MOD
    print(ans)


def __starting_point():
    main()

__starting_point()

N,K=map(int,input().split())
D=[0]*(K+1)
D[K]=1
mod=10**9+7
for i in range(K,0,-1):
  D[i]=pow(K//i,N,mod)
  for j in range(2*i,K+1,i):
    D[i]=(D[i]-D[j])%mod

c=0
for i in range(len(D)):
  c+=D[i]*i
print(c%mod)

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, K = LI()

# 逆に考える
"""
X = gcd(A_1, A_2,...A_K)
となるようなXを考えると溶ける
X = 3の時その個数は
[K/3]**N
"""

x_cnt = [0] * (K + 1)
for x in range(K, 0, -1):
    # print(x)
    tmp = pow(K // x, N, mod)
    for j in range(x + x, K+1, x):
        tmp -= x_cnt[j]
    x_cnt[x] = tmp

ans = 0
for i in range(1,K+1):
    ans += i * x_cnt[i]
    ans %= mod
print(ans)


    



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

for i in range(k, 0, -1):
    x = k // i
    m = n
    while m > 0:
        if m & 1:
            g[i-1] = g[i-1] * x % mod
        x = x * x % mod
        m >>= 1

    y = 2
    while i * y <= k:
        g[i-1] -= g[i*y-1]
        y += 1

ans = 0
for i in range(k):
    ans = (ans + g[i] * (i + 1)) % mod

print(ans)


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

baig=[0]*(10**5+1)
exg=[0]*(10**5+1)

for i in range(1,k+1):
    baig[i]=pow(k//i,n,MOD)

for j in range(k,0,-1):
    exg[j]=baig[j]
    for jj in range(2*j,k+1,j):
        exg[j]-=exg[jj]
    exg[j]%=MOD
    ans+=exg[j]*j
    ans%=MOD

print((int(ans)))



MOD = 10**9 + 7
def mod_pow(p, q):
    res = 1
    while q > 0:
        if q & 1:
            res = (res * p) % MOD
        q //= 2
        p = (p * p) % MOD
    return res

def solve(n, k):
    dp = [0] * (k+1)
    ans = 0
    for x in range(k, 0, -1):
        dp[x] = mod_pow((k // x), n) - sum(dp[y] for y in range(2*x, k+1, x))
        dp[x] %= MOD
        ans += dp[x] * x
    return ans % MOD

n, k = map(int, input().split())
print(solve(n, k))

mod = 1000000007
n,k = map(int, input().split())
d = [0]*(k+1)
for i in range(1,k+1):
    d[i] = pow(k//i,n,mod)
for i in range(k,0,-1):
    for j in range(2*i,k+1,i):
        d[i] -= d[j]
        d[i] %= mod
ans = 0
for i in range(1,k+1):
    ans += d[i]*i
    ans %= mod
print(ans)

mod = 10 ** 9 + 7
N, K = map(int, input().split())

ans = 0
memo = [0] * (K + 1)
for i in range(K, 0, -1):
    x = K // i
    cnt = pow(x, N, mod)

    a = i
    while a <= K:
        cnt -= memo[a]
        a += i

    memo[i] = cnt
    ans += i * cnt
    ans %= mod

print(ans)

n,k = map(int,input().split())
mod = 10**9+7
"""
dp[i] := gcd(a1,...,an) = i となるものがいくつあるか
"""
dp = [0 for _ in range(k+1)]
subdp = [0 for _ in range(k+1)]
for i in range(1, k+1)[::-1]:
	target = pow(k//i, n, mod)
	for j in range(2*i, k+1, i):
		target -= dp[j]
	dp[i] = target
ans = 0
for i in range(k+1):
	ans = (ans + dp[i]*i) % mod
print(ans)

def modpow(val, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = (ret * val) % mod
        val = (val * val) % mod
        n = n >> 1
    return ret


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

my_dict = dict()
ret = 0

for i in range(k, 0, -1):
    tmp = modpow(k // i, n, mod)
    cnt = 2
    while True:
        val = i * cnt
        if val > k:
            break
        else:
            cnt += 1
            tmp -= my_dict[val]
    my_dict[i] = tmp
    ret += tmp * i % mod

print((ret % mod))


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

import numpy as np
MOD = 10 ** 9 + 7
N, K = list(map(int, input().split()))
gcds = np.zeros((K + 1,), dtype=np.int64)
for n in range(K, 0, -1):
    gcds[n] = (pow(K // n, N, MOD) - gcds[np.arange(1, K // n + 1, dtype=np.int64) * n].sum()) % MOD
print((gcds @ np.arange(K + 1) % MOD))


MOD = 10**9+7
N, K = list(map(int, input().split()))
t = {}
ans = 0

for i in range(K, 0, -1):
    n = pow(K//i, N, MOD)

    for j in range(2*i, K+1, i):
        n -= t[j]
    t[i] = n
    ans = (ans + i * n) % MOD
print(ans)

n,k=map(int,input().split())
MOD=10**9+7
l=[0]*(k+1)
for i in range(k,0,-1):
  l[i]=pow(k//i,n,MOD)
for i in range(k,0,-1):
  for j in range(k//i,1,-1):
    l[i]=(l[i]-l[i*j])%MOD
ans=0
for i,c in enumerate(l):
  ans+=i*c
  ans%=MOD
print(ans)

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

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

xs = [i for i in range(1, k + 1)]
xs.reverse()

dict_x = {}

mod = 10 ** 9 + 7

def pow(x, y):
    nonlocal mod
    a = 1
    b = x
    c = y
    while c > 0:
        if c & 1:
            a = (a * b) % mod
        b = (b * b) % mod
        c = c >> 1
    return a

answer = 0
for x in xs:
    num = k // x
    a = pow(num, n)
    # print(a)
    s = 2
    while x * s <= k:
        a -= dict_x[x * s]
        s += 1
    dict_x[x] = a
    answer = (answer + a * x) % mod

print(answer)

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

import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n -= n_gcd[k * m]
        n_gcd[k] = n % P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


def __starting_point():
    main()

__starting_point()

#from line_profiler import LineProfiler
 
N, K = list(map(int, input().split()))
mod = 10**9 + 7
def main():
  b = N
  blis = []
  c = 0
  while b >0:
    if b & 1 == 1:
      blis.append(c)
    c += 1
    b >>= 1


  def modpow(a, blis= blis, c = c):
    if a == 1:
      return 1
    else:
      res = 1
      li = []
      for _ in range(c):
        li.append(a%mod)
        a = a*a%mod
      for item in blis:
        res = res *li[item] %mod
      return res

    
  fact_count = [0 for _ in range(K+1)]
  for k in range(1, K+1):
    fact_count[k] = K//k

  ans = 0
  count = [0 for _ in range(K+1)]
  for k in range(K, 0, -1):
    x = 1*fact_count[k]
    cc = modpow(x)
    j = 2*k
    l = 2
    while(j<=K):
      cc -= count[j]
      l += 1
      j = k*l
    count[k] = cc
    cc = cc*k%mod
    ans += cc
    ans %= mod
  print(ans)
def __starting_point():
  main()
#prof = LineProfiler()
#prof.add_function(main)
#prof.runcall(main)
#prof.print_stats()

__starting_point()

from math import gcd 
N,K=list(map(int,input().split()))

mod=10**9+7

A=[0]*K

for i in range(K,0,-1):
    a=K//i
    b=pow(a,N,mod)
    A[i-1]=b

for i in range(K,0,-1):
    for j in range(K//i-1):
        c=i*(j+2)
        A[i-1]-=A[c-1]
        A[i-1]%=mod

s=0
for i in range(K):
    s+=A[i]*(i+1)
    s%=mod

print(s)


MOD = 10**9+7
n, k = map(int, input().split())
cnt = [0]*(k+1)
for i in range(1, k+1):
    cnt[i] = pow(k//i, n, MOD)


dp = [0]*(k+1)
for i in reversed(range(1, k+1)):
    if not cnt[i]:
        continue
    tmp = cnt[i]
    for j in range(2, k+1):
        if k < i*j:
            break
        tmp -= dp[i*j]
        tmp %= MOD
    dp[i] = tmp

ans = 0
for i in range(1, k+1):
    ans += i*dp[i]
    ans %= MOD

print(ans)

# E - Sum of gcd of Tuples (Hard)
MOD = 10**9+7

def pow_mod(x,n):
    if n==0:
        return 1
    elif n%2==0:
        return (pow_mod((x**2)%MOD,n//2))%MOD
    else:
        return (x*pow_mod((x**2)%MOD,n//2))%MOD

N,K = map(int,input().split())
ans = 0
rec = [0]*(K+1)
for X in range(K,0,-1):
    rec[X] = pow_mod(K//X,N)
    for i in range(2,K//X+1):
        rec[X] = (rec[X]-rec[i*X])%MOD
    ans = (ans+X*rec[X])%MOD
print(ans)

N, K = [int(n) for n in input().split()]
NUM = 1000000007

def modpow(a, b): # (a ** b) % NUM
    ans = 1
    while b != 0:
        if b % 2 == 1:
            ans *= a
            ans %= NUM
        a = a * a
        a %= NUM
        b //= 2
    return ans

C = [0 for _ in range(K+1)]
for d in range(K):
    k = K - d # K ... 1
    L = K // k
    C[k] = modpow(L, N) # A = 1*k ... L*k
    for l in range(2, L+1):
        C[k] -= C[l*k]
        if C[k] < 0:
            C[k] += NUM
        C[k] %= NUM

ans = 0
for k in range(1, K+1):
    ans += k * C[k]
    ans %= NUM
print(ans)



import numpy as np
MOD = 10 ** 9 + 7
N, K = list(map(int, input().split()))
gcds = np.zeros((K + 1,), dtype=np.int64)
for n in range(K, 0, -1):
    gcds[n] = (pow(K // n, N, MOD) - gcds[np.arange(1, K // n + 1, dtype=np.int64) * n].sum()) % MOD
print((gcds @ np.arange(K + 1, dtype=np.int64) % MOD))


import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    n_multiple = [0] * (K + 1)
    for k in range(1, K + 1):
        n_multiple[k] = K // k

    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(n_multiple[k], N, mod=P)
        m = 2
        kk = k * m
        while kk <= K:
            n_gcd[k] = (n_gcd[k] - n_gcd[kk]) % P
            m += 1
            kk = k * m

    ans = 0
    for k in range(1, K + 1):
        ans = (ans + k * n_gcd[k]) % P
    print(ans)


def __starting_point():
    main()

__starting_point()


mod = pow(10, 9) + 7

def main():
    N, K = list(map(int, input().split()))
    table = [0]*(K+1)
    for k in range(K, 0, -1):
        m = K//k
        tmp = pow(m, N, mod)
        for l in range(2, m+1):
            tmp -= table[l*k]
            tmp %= mod
        table[k] = tmp

    ans = 0
    for i in range(len(table)):
        ans += (i * table[i])%mod
    ans %= mod
    #print(table)
    print(ans)


def __starting_point():
    main()

__starting_point()

# E - Sum of gcd of Tuples (Hard)
# https://atcoder.jp/contests/abc162/tasks/abc162_e

MOD = 10 ** 9 + 7

n, k = list(map(int, input().split()))
dic = [0] * (k + 1)

ans = 0
for i in range(k, 0, -1):
  dic[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
  for j in range(i * 2, k + 1, i):
    dic[i] -= dic[j]
    dic[i] %= MOD

ans = 0
for i in range(1, k + 1):
  ans += dic[i] * i
  ans %= MOD

print(ans)



import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] -= n_gcd[k * m]
        n_gcd[k] %= P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


def __starting_point():
    main()

__starting_point()

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()

gcd_cnt = [0]*(K+1)
ans = 0
for i in range(K, 0, -1):
	cnt = pow(K//i, N, mod)
	for j in range(2, K//i+1):
		cnt -= gcd_cnt[j*i]
		cnt %= mod
	gcd_cnt[i] = cnt
	ans += i*cnt
	ans %= mod

print(ans)


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

B=[0 for i in range(K+1)]
for i in range(K+1)[::-1]:
    if i==0: continue
    B[i]=pow((K//i),N,MOD)
    t=i*2
    while t<=K:
        B[i]-=B[t]
        t+=i

ans=0
for i in range(K+1):
    ans+=i*B[i]
    ans%=MOD
print(ans)

import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] = (n_gcd[k] - n_gcd[k * m]) % P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


def __starting_point():
    main()

__starting_point()

def sumGCD(N,K,M):
    dp = [None for _ in range(K+1)]
    #dp[i]:gcd(A) % i == 0を満たすAの個数
    for i in reversed(list(range(1,K+1))):
        dp[i] = pow(K//i,N,M)
        for j in range(2,K//i+1):
            dp[i] -= dp[i*j]
            dp[i] %= M

    output = 0
    for i in range(1,K+1):
        output += (dp[i]*i)
        output %= M

    return output

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

    print((sumGCD(N,K,10**9+7)))

def __starting_point():
    main()

__starting_point()

N, K = list(map(int, input().split()))
MOD = 10 ** 9 + 7
lst = [0] + [pow(K // d, N, MOD) for d in range(1, K + 1)]

for d in range(K, 0, -1):
    lst[d] -= sum(lst[d * i] for i in range(2, K // d + 1))

ans = 0
for i, x in enumerate(lst):
    ans = (ans + i * x) % MOD
print(ans)


MOD=10**9+7
N,K=map(int,input().split())
d=[0]
d+=[pow(K//i,N,MOD) for i in range(1,K+1)]
for i in reversed(range(1,K+1)):
    j=2
    while(i*j<=K):
        d[i]=(d[i]-d[i*j]+MOD)%MOD
        j+=1
ans=0
for i in range(1,K+1):
    ans=(ans+d[i]*i%MOD)%MOD
print(ans)


def solve(N, K):
    mod = 10 ** 9 + 7
    multiples = [[] for _ in range(K + 1)]
    for k in range(1, K + 1):
        for i in range(k, K + 1, k):
            multiples[k].append(i)

    gcdcounts = [0] * (K + 1)  # gcd 毎の組み合わせ個数
    gcdsums = [0] * (K + 1)   # gcd 毎の合計値
    for k in reversed(list(range(1, K + 1))):
        x = pow(len(multiples[k]), N, mod)
        for l in multiples[k]:
            x -= gcdcounts[l]
        gcdcounts[k] = x % mod
        gcdsums[k] = x * k % mod
    print((sum(gcdsums) % mod))


def __starting_point():
    N, K = list(map(int, input().split()))
    solve(N, K)

__starting_point()

N, K = list(map(int, input().split()))
MOD = 1_000_000_007
gcd_cnt = [0] * (K + 1)
for g in range(K, 0, -1):
    gcd_cnt[g] = pow(K // g, N, MOD)
    for g_mul in range(2, K // g + 1):
        gcd_cnt[g] -= gcd_cnt[g * g_mul]

ans = 0
for g, cnt in enumerate(gcd_cnt):
    ans += g * cnt % MOD
    ans %= MOD
print(ans)


n,k=map(int,input().split())
mod=10**9+7
count=[0]*(k+1)
def getnum(m):
    ret = pow(k//m,n,mod)
    mul=2
    while m*mul<=k:
        ret-=count[m*mul]
        mul+=1
    return ret%mod
ans=0
for i in range(1,k+1)[::-1]:
    g=getnum(i)
    count[i]=g
    ans+=g*i
    ans%=mod
print(ans)

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

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

l = [0]*(k+1)

for i in range(k,0,-1):
  m = k//i
  l[i] += pow(k//i,n,mod)
  for j in range(2,m+1):
    l[i] -= l[i*j]

ans = 0
for i in range(k+1):
  ans += i*l[i] % mod
  ans %= mod
print(ans)

Mod = 1000000000 + 7

def fastpow(x,y):
    ans = 1

    nonlocal Mod
    while y:
        if (y & 1): ans = (ans * x) % Mod
        x = (x * x) % Mod
        y >>= 1
    return ans

def solve(N,K):
    # f[i] is number (x1,....xn) such that gcd(x1,..,xK) = i
    
    f = [0]*(K + 1)
    for i in range(K,0,-1):
        f[i] = fastpow(K//i,N)
        for j in range(i + i,K + 1,i):
            f[i] -= f[j]

    nonlocal Mod
    ans = 0
    for i in range(1,K + 1):
        ans = (ans + i*f[i]) % Mod
    return ans


def __starting_point():
    
    N, K = list(map(int,input().split()))
    print((solve(N,K)))

__starting_point()

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, K: int):
    num_gcd = {}
    for k in range(K, 0, -1):
        num_select = K // k
        num_gcd_k = pow(num_select, N, MOD)
        for multiple in range(2, num_select+1):
            num_gcd_k -= num_gcd[k * multiple]
        num_gcd[k] = num_gcd_k

    result = 0
    for k in range(1, K+1):
        result += (k * num_gcd[k]) % MOD
    print((result % MOD))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

def __starting_point():
    main()

__starting_point()

import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    n_multiple = [0] * (K + 1)
    for k in range(1, K + 1):
        n_multiple[k] = K // k

    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(n_multiple[k], N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] = (n_gcd[k] - n_gcd[k * m]) % P

    ans = 0
    for k in range(1, K + 1):
        ans = (ans + k * n_gcd[k]) % P
    print(ans)


def __starting_point():
    main()

__starting_point()

N,K = list(map(int, input().split()))
mod = int(1e9+7)
A = [0] * (K+1)
ans = 0

for i in range(K,0,-1):
  #print(i, K//i, N, mod)
  A[i] = pow(K//i, N, mod)
  idx = 2*i
  while idx <= K:
    A[i] = (A[i] - A[idx]) % mod
    idx += i
  ans = (ans + A[i] * i) % mod
print(ans)


import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: list(map(int, sys.stdin.readline().split()))
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

MOD = 10 ** 9 + 7
N, K = nm()


def solve():
    ans = 0
    tbl = [0] * (K + 1)
    for i in range(K, 0, -1):
        m = K // i
        p = pow(m, N, MOD)

        j = 2
        while j * i <= K:
            p += MOD - tbl[j * i] % MOD
            p %= MOD
            j += 1
        tbl[i] = p

        ans += i * p % MOD
        ans %= MOD
    return ans


print((solve()))


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

L = [0]*(k+1)

for i in range(k,0,-1):    
  L[i] = pow(k//i,n,MOD)
  for j in range(2,k//i+1):        
    L[i] -= L[i*j]
  
ans = 0
for i in range(1,k+1):  
  ans = (ans + i*L[i]) % MOD
  
print(ans)  

mod = 10**9 + 7
n,k= [int(i) for i in input().split()]

d = [0] * (k + 1)

for i in range(1,k+1):
    d[i] = pow(k//i,n,mod)
    
    
for i in range(k,0,-1):
    for j in range(2*i,k+1,i):
        d[i] -= d[j]
        d[i] %= mod
        
ans = 0 
for idx,i in enumerate(d):
    ans += (idx) * i
    ans %= mod

print(ans)


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


N, K = list(map(int, input().split()))
d = [0]*(K+1)
MOD = 10**9+7
for i in range(1, K+1):
    d[i] = pow(K//i, N, MOD)
for i in range(K, 0, -1):
    for j in range(2*i, K+1, i):
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i in range(1, K+1):
    ans += d[i]*i
    ans %= MOD
print(ans)



n,k=list(map(int,input().split()))
m=1000000007
ans=0
dp=[0]*(k+1) #dp[i]:=iを数列内の最大値とするもののgcd合計
for i in range(k,0,-1):
  mul_i=k//i#iの倍数の個数
  dp[i]=pow(mul_i,n,m)
  for j in range(2,mul_i+1):
    dp[i]=(m+dp[i]-dp[i*j])%m
  ans+=i*dp[i]%m
ans%=m
print(ans)






N,K = map(int,input().split())
mod = 10**9+7
ans = 0

data = [0]*(K+1)
for x in range(K,0,-1):
    p = pow(K//x,N,mod)
    for k in range(2,K//x+1):
        p -= data[k*x]
        p %= mod
    data[x] = p
    ans += x*p
    ans %= mod

###
#print(data)
###
    
print(ans)

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()

gcd_cnt = [0]*(K+1)

for i in range(K, 0, -1):
	cnt = pow(K//i, N, mod)
	for j in range(2, K//i+1):
		cnt -= gcd_cnt[j*i]
		cnt %= mod
	gcd_cnt[i] = cnt

ans = 0
for i, x in enumerate(gcd_cnt):
	ans += i*x
	ans %= mod

print(ans)


n, k = list(map(int, input().split()))
MOD = 1000000007
cnt = [0] * (k + 1)
for i in range(1, k + 1):
    cnt[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
    j = i * 2
    while j <= k:
        cnt[i] = (MOD + cnt[i] - cnt[j]) % MOD
        j += i
ans = 0
for i in range(1, k + 1):
    ans = (ans + cnt[i] * i) % MOD
print(ans)



MOD=10**9 + 7
n,k=map(int,input().split())
mp = [0]*(k+1)
for i in range(k,0,-1):
    mp[i]=pow(k//i,n,MOD)
    t=2
    while i*t<=k:
        mp[i]-=mp[t*i]
        t+=1
ans=0
for i in range(1,k+1):
    ans += i * mp[i]
print(ans % MOD)

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


mod = 1000000007
n,k = map(int, input().split())
d = [0]*(k+1)
for i in range(1,k+1):
    d[i] = pow(k//i, n, mod)
for i in range(k,0,-1):
    for j in range(2*i, k+1, i):
        d[i] -= d[j]
        d[i] %= mod
ans = 0
for i in range(1,k+1):
    ans += d[i]*i
    ans %= mod
print(ans)

N, K = map( int, input().split() )
mod = 10 ** 9 + 7
Cnt = [ 0 ] * ( K + 1 )

for i in range( K, 0, -1 ):
  elem_cnt = K // i
  i_s_cnt = pow( elem_cnt, N, mod)
  for j in range( 2, elem_cnt + 1 ):
    i_s_cnt -= Cnt[ i * j ]
  Cnt[ i ] = i_s_cnt

cnt = 0
for i , c in enumerate( Cnt ):
  cnt += i * c
  cnt = cnt % mod 

print( cnt )

MOD = 10**9 + 7

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

nums = [0] * (K+1)
for i in reversed(list(range(1, K+1))):
    num = pow(K//i, N, MOD)
    for j in range(2*i, K+1, i):
        num -= nums[j]
    nums[i] = num % MOD

ans = 0
for i in range(1, K+1):
    ans += i * nums[i] % MOD
    ans %= MOD

print(ans)


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

s = [0] * (k + 1)
ans = 0

for i in range(k, 0, -1):
    s[i] += pow(int(k / i), n, int(1e9 + 7))
    s[i] %= 1e9 + 7
    for j in range(i * 2, k + 1, i):
        s[i] += 1e9 + 7
        s[i] -= s[j]
        s[i] %= 1e9 + 7

for i in range(1, k+1):
    ans += i * s[i]
    ans %= 1e9 + 7

ans %= 1e9+7

print(int(ans))

N, K = map(int,input().split())
MOD = 10**9+7
ls = [0]*(K+1) #個数
for i in range(1, K+1)[::-1]:
  ls[i] =  pow(K // i, N, MOD)
  if K // i != 1:
    a = K // i
    for j in range(2, a+1):
      ls[i] -= ls[i*j]  
    
ans = 0
for i in range(1, K+1):
  ans += i * ls[i]
  ans %= MOD  
print(ans) 

N, K = list(map(int, input().split()))
mod = 10**9 + 7
cnt = [0]*(K+1)
ans = 0
for g in range(K, 0, -1):
    sub = sum(cnt[2*g:K+1:g])
    q = pow(K//g, N, mod) - sub
    ans = (ans + g * q) % mod
    cnt[g] = q
print(ans)


def left_bin(a, n, c):
    ns = [int(i) for i in bin(n)[3:]]
    t = a
    for i in ns:
        t = t*t % c
        if i == 1:
            t = t*a % c
    return t


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


import math
from collections import defaultdict

N,K = list(map(int,input().split()))
mod = 10**9+7
DP = [0]*(K+1)  #DP[i]:gcd=iとなる数列の個数
ans = 0

for i in range(K,0,-1):
    m = K//i    #m:iの倍数の個数
    DP[i] = pow(m,N,mod)
    for j in range(2,m+1):
        DP[i] -= DP[i*j]
    ans += (DP[i]*i) % mod
    ans %= mod

print(ans)


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

  
fact_count = [0 for _ in range(K+1)]
for k in range(1, K+1):
  fact_count[k] = K//k

ans = 0
count = [0 for _ in range(K+1)]
for k in range(K, 0, -1):
  c = pow(fact_count[k], N, mod)
  j = 2*k
  l = 2
  while(j<=K):
    c -= count[j]
    l += 1
    j = k*l
  count[k] = c
  c = c*k%mod
  ans += c
  ans %= mod
print(ans)



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


#%%
ans = 0
gcds = [0]*(K+1)
for i in reversed(list(range(1, K+1))):
    gcds[i] = pow(K//i, N, MOD)
    idx = i*2
    while idx<K+1:
        gcds[i] -= gcds[idx] + MOD
        gcds[i] %= MOD
        idx += i
    ans += (i * gcds[i])
    ans %= MOD


print(ans)



import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n = pow(K // k, N, mod=P)
        for kk in range(2 * k, K + 1, k):
            n -= n_gcd[kk]
        n_gcd[k] = n % P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


def __starting_point():
    main()

__starting_point()

mod = 10**9 + 7
n, k = map(int,input().split())
cnt = [0]*(k+1)

for i in range(k, 0, -1):
  cnt[i]+=pow(k//i,n,mod)
  for j in range(2, k//i+1):
    cnt[i]-=cnt[i*j]
ans = 0
for i in range(1, k+1):
  ans+=i*(cnt[i])%mod
  ans%=mod
  
print(ans)

n, k = map(int, input().split())
MOD = 10 ** 9 + 7
d = [0] * (k + 1)

for i in range(1, k + 1):
    d[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
    for j in range(i * 2, k + 1, i):
        d[i] -= d[j]
        d[i] %= MOD

ans = 0
for i in range(1, k + 1):
    ans += d[i] * i
    ans %= MOD
print(ans)

import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = dict.fromkeys(list(range(K + 1)), 0)
    for k in reversed(list(range(1, K + 1))):
        n_gcd[k] = pow(K // k, N, mod=P)
        for m in range(2, K // k + 1):
            n_gcd[k] = (n_gcd[k] - n_gcd[k * m]) % P
        ans = (ans + k * n_gcd[k]) % P

    print(ans)


def __starting_point():
    main()

__starting_point()

N, K = [int(i) for i in input().split()]
MOD = 10**9 + 7

class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


memo = [-1] * K
def count(k):
    if(memo[k-1] != -1):
        return memo[k-1]
    
    if(k > K//2):
        memo[k-1] = ModInt(1)
        return memo[k-1]
    
    res = ModInt(K//k) ** N
    for i in range(2, K//k + 1):
        res -= count(i * k)

    memo[k-1] = res
    return res

ans = 0
for k in range(K, 0, -1):
    ans += count(k) * k
print(ans)

n,k=map(int,input().split())
m=10**9+7
l=[0]*(k+1)
a=0
for i in range(k,0,-1):
 l[i]=pow(k//i,n,m)
 for j in range(2,k//i+1):l[i]-=l[i*j]
 a+=i*l[i]
 a%=m
print(a)

n,k=map(int,input().split())
num=[0]*k
ans=0

def njo(arg,n):
  if n==0:
    return 1
  elif n%2==0:
    return njo((arg**2)%1000000007,n//2)
  else:
    return arg*njo((arg**2)%1000000007,n//2)

for i in range(k):
  test=k-i
  num[test-1]=njo(k//test,n)
  mul=test*2
  while mul<=k:
    num[test-1]-=num[mul-1]
    mul+=test

  ans+=num[test-1]*test
  
while ans<0:
  ans+=1000000007
print(str(ans%1000000007))

import sys

input = sys.stdin.readline
P = 10 ** 9 + 7


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

    ans = 0
    n_gcd = [0] * (K + 1)
    for k in reversed(list(range(1, K + 1))):
        n = pow(K // k, N, mod=P)
        for kk in range(2 * k, K + 1, k):
            n -= n_gcd[kk]
        n_gcd[k] = n % P
        ans += k * n_gcd[k]
        ans %= P

    print(ans)


def __starting_point():
    main()

__starting_point()

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
#INF = float("inf")
#MOD = 10**9+7
MOD = 10**9+7
import math
N,K = map(int,input().split())
ans = [0]*K
for i in range(K):
    p = K-i
    a = pow(math.floor(K/p),N,MOD)
    x = 1
    while p*(x+1) <= K:
        a -= ans[p*(x+1)-1]
        x = x+1
    ans[p-1] = a%MOD
s = 0
for i in range(K):
    s += (i+1)*ans[i]
    s = s%MOD
print(s)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

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

lst = [0] * (K + 1)

for i in range(K, 0, -1):
    a = K // i
    tmp = pow(a, N, MOD)
    for j in range(i + i, K + 1, i):
        tmp -= lst[j]
    lst[i] = tmp

ans = 0
for i in range(K + 1):
    ans += i * lst[i]
    ans %= MOD

print (ans)

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n, k = map(int, input().split())
    mod = 10 ** 9+ 7
    table = [0]*(k+1)
    ans= 0
    for i in range(k, 0, -1):
        table[i] = pow(k//i, n, mod)
        j = 2
        while i*j <= k:
            table[i] -= table[i*j]
            table[i] %= mod
            j += 1
        ans += i*table[i]
        ans %= mod
    print(ans)



def __starting_point():
    main()
__starting_point()

n,k = map(int,input().split())
mod = 1000000007
cnt = [0]*(k+1)
for i in range(1,k+1)[::-1]:
    cnt[i] = pow(k//i,n,mod)
    for j in range(2*i,k+1,i):
        cnt[i] -= cnt[j]
        cnt[i] %= mod
ans = 0
for i in range(1,k+1):
    ans += cnt[i]*i
    ans %= mod
print(ans)

MOD = 10 ** 9 + 7

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

divisor_lst = [i - 1 for i in range(1, k + 1)]
divisor_lst[0] = 1

for i in range(2, k):
    for j in range(2 * i, k + 1, i):
        divisor_lst[j - 1] -= divisor_lst[i - 1]

ans = 0
for num in range(1, k + 1):
    ans += pow(k // num, n, MOD) * divisor_lst[num - 1]
    ans %= MOD
print(ans)

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

N, K = list(map(int, input().split()))
MOD = 10**9 + 7
memo = {}


def a(n):
    if n in memo:
        return memo[n]
    else:
        ret = pow(n, N, MOD)
        for i in range(2, n+1):
            ret -= a(n//i)
        memo[n] = ret
        return ret


ans = 0
for i in range(1, K+1):
    ans += i*a(K//i)
    ans %= MOD
print(ans)


N, K = [int(_) for _ in input().split()]
mod = 10**9 + 7
A = [0] * (K + 1)
for i in range(K, 0, -1):
    A[i] = pow(K // i, N, mod)
    for j in range(2, K // i + 1):
        A[i] -= A[i * j]
        A[i] %= mod
print((sum(i * a for i, a in enumerate(A)) % mod))


mod = 1000000007
n, k = map(int, input().split())

d = [0] * (k + 1)

for i in range(1, k + 1):
    d[i] = pow(k//i, n, mod)

for i in range(k, 0, -1):
    for j in range(2*i, k + 1, i):
        d[i] -= d[j]
        d[i] %= mod

ans = 0
for i in range(i, k+1):
    ans += d[i] * i

ans %= mod
print (ans)

# 解説AC
mod = 10 ** 9 + 7
n, k = list(map(int, input().split()))
dp = [-1] * (k + 1)
ans = 0
for i in range(k, 0, -1):
    dp[i] = pow(k // i, n, mod)
    t = 0
    t += 2 * i
    while t <= k:
        dp[i] -= dp[t]
        dp[i] %= mod
        t += i
    ans += i * dp[i]
    ans %= mod
print(ans)


N,K=map(int,input().split())
m=10**9+7
d=[0]*K
for k in range(K,0,-1):
    d[k-1]=pow(K//k,N,m)
    for l in range(2*k,K+1,k):
        d[k-1]=(d[k-1]-d[l-1])%m
print(sum([(k+1)*d[k]%m for k in range(K)])%m)

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

mod = 10**9 + 7
cnt = [0]*(k + 1)
ans = 0
for i in range(k, 0, -1):
    cnt[i] = (pow(k//i, n, mod) - sum(cnt[2*i:k+1:i])) % mod
    ans = (ans + i*cnt[i]) % mod

print(ans)



def resolve():
    MOD = 10**9+7
    N, K = map(int, input().split())
    cnt = [0]*(K+1)

    for g in range(K, 0, -1):
        cnt[g] = pow(K//g, N, MOD) # (K//g)**N
        gg = g*2
        while gg <= K:
            cnt[g] -= cnt[gg]
            gg += g
    ans = 0
    for g in range(1, K+1):
        ans += cnt[g] * g
        ans %= MOD
    print(ans)    

def __starting_point():
    resolve()
__starting_point()

Q = 10**9+7
def main():
    N, K = list(map( int, input().split()))
    ANS = [0]*(K+1)
    for x in range(K,0,-1):
        ans = pow(K//x,N,Q)
        for i in range(2, K+1):
            if x*i > K:
                break
            ans -= ANS[x*i]
        ANS[x] = ans%Q
    print(( sum( [ANS[i]*i%Q for i in range(K+1)])%Q))
        
def __starting_point():
    main()

__starting_point()

import sys
import os

def file_input():
    f = open('Beginner_Contest_162/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()

    N,K=list(map(int, input().split()))   #K以下、Nの長さ

    tmp=[0]*(K+1)
    mod=10**9+7
    out=0

    for i in range(K,0,-1):
        tmp[i]=pow(K//i,N,mod)  #iの倍数はK/i個ある。それがN個並んでいる
        for j in range(i*2,K+1,i):
            tmp[i]-=tmp[j]
        out+=tmp[i]*i

    print((out%mod))

def __starting_point():
    main()

__starting_point()