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 <vector>
#include <cstdio>
#include <algorithm>
 
typedef long long ll;
inline int Get() {
	char ch;
	while ((ch = getchar()) < '0' || ch > '9');
	int Num = ch - '0';
	while ((ch = getchar()) >= '0' && ch <= '9')
		Num = (Num << 3) + (Num << 1) + ch - '0';
	return Num;
}
const int Mod = 1e9 + 7;
int n, m, ans;
std :: vector <int> v, g;
inline int pow(int x, int k) {
	ll res = 1, r = x % Mod;
	for (; k; k >>= 1, r = r * r % Mod) 
		if (k & 1) res = res * r % Mod;
	return res;
}
int main() {
	n = Get(), m = Get();
	for (int i = 1; (ll)i * i <= n; ++i)
		if (!(n % i)) {
			v.push_back(i), g.push_back(0);
			if (n / i != i) v.push_back(n / i), g.push_back(0);
		}
	
	std :: sort(v.begin(), v.end());
	for (int i = 0, sze = v.size(), x; i < sze; ++i) {
		x = v[i], g[i] = pow(m, x + (x & 1) >> 1);
		for (int j = 0; j < i; ++j)
			if (!(x % v[j])) g[i] = (g[i] - g[j] + Mod) % Mod;
	} 
	
	for (int i = 0, sze = v.size(), x; i < sze; ++i)
		x = v[i], (ans += (ll)((x & 1) ? x : x >> 1) * g[i] % Mod) %= Mod;
	printf("%d\n", ans);
}