Takahashi and Aoki are going to together construct a sequence of integers.

First, Takahashi will provide a sequence of integers a, satisfying all of the following conditions:

* The length of a is N.
* Each element in a is an integer between 1 and K, inclusive.
* a is a palindrome, that is, reversing the order of elements in a will result in the same sequence as the original.



Then, Aoki will perform the following operation an arbitrary number of times:

* Move the first element in a to the end of a.



How many sequences a can be obtained after this procedure, modulo 10^9+7?

Constraints

* 1≤N≤10^9
* 1≤K≤10^9

Input

The input is given from Standard Input in the following format:


N K


Output

Print the number of the sequences a that can be obtained after the procedure, modulo 10^9+7.

Examples

Input

4 2


Output

6


Input

1 10


Output

10


Input

6 3


Output

75


Input

1000000000 1000000000


Output

875699961
#include<cstdio>
typedef long long ll;
const int mod=1000000007,I2=mod+1>>1;
ll pw(ll a,int n){ll b=1;for(;n;n>>=1)n%2?b=b*a%mod:1,a=a*a%mod;return b;}
int p[20],c[20],cnt;
ll dfs(int i,int x,int K){
	if(i==cnt)return pw(K,x+1>>1)*x%mod;
	ll s=0,t;
	for(int k=0,w=1;k<=c[i];k++,w*=p[i]){
		t=w&1?1:I2;
		if(k<c[i])(t+=(mod-p[i])*1ll*(w*p[i]&1?1:I2))%=mod;
		(s+=dfs(i+1,x*w,K)*t)%=mod;
	}
	return s;
}
int calc(int N,int K){
	int x=N;cnt=0;
	for(int i=2;i*i<=x;i++)if(x%i==0){
		p[cnt]=i,c[cnt]=0;
		while(x%i==0)c[cnt]++,x/=i;
		cnt++;
	}
	if(x>1)p[cnt]=x,c[cnt++]=1;
	return dfs(0,1,K);
}
int main(){
	int N,K;
	scanf("%d%d",&N,&K);
	printf("%d\n",calc(N,K)); 
}