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: Accepted)

#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 繰り返し二乗法 (xのy乗) */
ll binpow(ll x, ll y)
{
	ll res = 1LL;
	x %= MOD;
	while (y) {
		if (y & 1) res = (res * x) % MOD;
		y >>= 1;
		x = (x * x) % MOD;
	}
	return res;
}

int main()
{
	ll N, K;
	cin >> N >> K;

	vector<ll> powRes(K + 1, 0);
	REPN(i, 1, K + 1) {
		powRes[i] = binpow(K / i, N);
	}

	vector<ll> cmbNum(K + 1, 0);
	for (ll i = K; i >= 1; i--) {
		ll jufukuNum = 0;
		for (ll j = i * 2; j <= K; j += i) {
			jufukuNum += cmbNum[j];
			jufukuNum %= MOD;
		}
		ll cmbOne = powRes[i] - jufukuNum + 2 * MOD;
		cmbNum[i] = cmbOne % MOD;
	}

	ll ans = 0;
	REPN(i, 1, K + 1) {
		ans += cmbNum[i] * i;
		ans %= MOD;
	}

	cout << ans << endl;
	return 0;
}