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<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
 
ll Pmod(ll n,ll k){
	ll r=k,ret=1;
	while(true){
		if(n==0)break;
		if(n%2==1){
			ret=ret*r%mod;
		}
		n/=2;
		r=r*r%mod;
	}
	return ret;
}
 
vector<pair<ll,ll> > v;
int main(){
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i*i<=n;i++){
		if(n%i==0){
			v.push_back(make_pair(i,-1));
			if(i!=n/i)v.push_back(make_pair(n/i,-1));
		}
	}
	sort(v.begin(),v.end());
	ll ans[2]={0,0};
	for(int i=0;i<v.size();i++){
		ll x=v[i].first;
		ll tmp=Pmod((x+1)/2,k);
		for(int j=0;j<i;j++){
			if(x%v[j].first==0){
				tmp=(mod+tmp-v[j].second)%mod;
			}
		}
		v[i].second=tmp;
		ans[x%2]+=tmp*x%(mod*(ll)10);
	}
	//cout<<ans[0]<<" "<<ans[1]<<endl;
	cout<<(ans[0]/2+ans[1])%mod<<endl;
	return 0;
}