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# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
			var intArray = IO.ReadIntArray();
			var combinationNum = intArray[0];
			var numberMax = intArray[1];

			var gcdSum = 0L;
			var gcdNums = new long[numberMax + 1];
			for(var iIndex = numberMax ; iIndex >= 1 ; -- iIndex) 
			{
				var num = Util.ModPow(numberMax / iIndex , combinationNum , ModNumber);
				for(var iSubtractIndex = iIndex * 2 ; iSubtractIndex <= numberMax ; iSubtractIndex += iIndex)
				{
					num -= gcdNums[iSubtractIndex];
				}
				gcdNums[iIndex] = num % ModNumber;
				gcdSum += ((iIndex * gcdNums[iIndex]) % ModNumber);
			}
			IO.Write(gcdSum % ModNumber);
		}
		private const long ModNumber = 1000000007;
	}

	public static class IO
	{
		public static string   Read()							  { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')	  { return Read().Split(iSplitter); }
		public static int	   ReadInt()						  { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ') { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()					  { return Read().ToCharArray(); }

		public static void Write(string iValue)  { Console.WriteLine(iValue); }
		public static void Write(int iValue)	 { Console.WriteLine(iValue); }
		public static void Write(long iValue)	 { Console.WriteLine(iValue); }
		public static void Write(decimal iValue) { Console.WriteLine(iValue); }
		public static void Write(bool iValue)	 { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1)	{ return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i0 , i1); }
		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
	}
}