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 C++ (GCC 9.2.1) (judge verdict: Runtime Error)

/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog oi.ender-zzm.pro
*/
#include <bits/stdc++.h>
using namespace std;

template<class T>
inline void read(T &a) {
    register T x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
    a = x * flag;
}

template <class T>
inline void write(T x) {
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, a, b) for (int i = (a); i <= (b); i++) 
#define Rep(i, a, b) for (int i = (a); i >= (b); i--) 
#define For_edge(x) for (int i = head[x]; i; i = net[i])
#define mem0(a) memset(a, 0, sizeof a)

#define int long long
const int maxn = 501000;
const int Mod = 1e9 + 7;
int n, k;
int prime[maxn], tot, vis[maxn], phi[maxn];
int S[maxn];
int Get_phi(int n) {
	phi[1] = 1;
	For(i, 2, n) {
		if (vis[i] == 0) {
			prime[++tot] = i;
			phi[i] = i - 1;
		}
		For (j, 1, tot) {
			int v = i * prime[j];
			if (v > n) break;
			vis[v] = 1;
			if (i % prime[j] == 0) {
				phi[v] = phi[i] * prime[j];
				break;
			}
			phi[v] = phi[i] * (prime[j] - 1);
		}
	}
	For (i, 1, n) {
		S[i] = (S[i - 1] + phi[i]) % Mod;
	}
}
int Pow(int x, int y) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = 1ll * ans * x % Mod;
		x = 1ll * x * x % Mod;
		y >>= 1;
	}
	return ans;
}
signed main() {
	int ans = 0;
	cin >> n >> k;
	Get_phi(k);
	int l = 1, r = 0;
	for (l, r; l <= k; l = r + 1) {
		r = min(k, k / (k / l));
		ans = (ans + 1ll * (S[r] - S[l - 1] + Mod) % Mod * Pow(k / l, n) % Mod) % Mod;
	}
	cout << ans;
}