Problem:
Score : 500 points

Problem Statement

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 1

3 2

Sample Output 1

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.

Sample Input 2

3 200

Sample Output 2

10813692

Sample Input 3

100000 100000

Sample Output 3

742202979

Be sure to print the sum modulo (10^9+7).

Solution in PyPy3 (7.3.0) (judge verdict: Accepted)

#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    #1がひとつでもある：gcd(A) ==1
    #1を含む数列のパターン数：K**N - (K-1)**N

    #最低が2,全部偶数：gcd(A) == 2
    #そのような数列のパターン数p2：(K//2)**N - (K//2-1)**N

    #最低が3,全部3の倍数：gcd(A) == 3
    #p3:(K//3)**N - (K//3-1)**N



    #1<=d<=K
    #gcd(A)==dとなるようなパターン数：(K//D)**N-(K//D*2)**N-...
    ans = 0
    P = {}
    for i in range(K,0,-1):
        t = 2
        p = pow((K//i),N,MOD)
        while i*t<=K:
            p -= P[t*i]
            t += 1
        P[i] = p
        ans += p*i
        ans %= MOD
    print(ans)





    # ans = 0
    # notgcd1 = 0 
    # for i in range(1,K+1):
    #     p = pow((K//i),N,MOD) - pow((K//i-1),N,MOD)
    #     notgcd1 += pow((K//i),N,MOD) - p
    #     notgcd1 %= MOD
    #     ans += p*i
    #     ans %= MOD
    # ans += pow(K,N,MOD)-notgcd1
    # ans %= MOD
    # print(ans)



if __name__ == '__main__':
    main()