#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
const int mod = (int)1e9 + 7;
int mul(int a, int b) { return (long long)a * b % mod; }
void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
const int maxn = (int)1e5 + 5;
int lDiv[maxn];
vector<int> pr;
int mu[maxn];
void precalc() {
  for (int i = 2; i < maxn; i++) {
    if (!lDiv[i]) {
      lDiv[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < ((int)(pr).size()) && pr[j] <= lDiv[i]; j++) {
      int p = pr[j] * i;
      if (p >= maxn) {
        break;
      }
      lDiv[p] = pr[j];
    }
  }
  mu[1] = 1;
  for (int i = 2; i < maxn; i++) {
    int pi = i / lDiv[i];
    if (lDiv[pi] == lDiv[i]) {
      mu[i] = 0;
      continue;
    }
    mu[i] = -mu[pi];
  }
}
pair<int, int> gcd(int a, int b) {
  if (!b) {
    return make_pair(1, 0);
  }
  pair<int, int> p = gcd(b, a % b);
  return make_pair(p.second, p.first - (a / b) * p.second);
}
int inv(int x) {
  int res = gcd(x, mod).first;
  return (res % mod + mod) % mod;
}
int n, k;
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  return true;
}
int pk[maxn];
int cnt[2 * maxn];
void solve() {
  pk[0] = 1;
  for (int i = 1; i < maxn; i++) {
    pk[i] = mul(pk[i - 1], k);
  }
  int res = 0;
  for (int i = 1; i < n; i++) {
    add(res, pk[n - i]);
  }
  for (int d = 1; d < n; d++) {
    for (int i = 1; i * d < 2 * n; i++) {
      cnt[i] = (i - 1) / 2;
      if (i * d >= n) {
        int j = i - (n + d - 1) / d;
        cnt[i] -= j;
      }
    }
    for (int r = 2; r * d < n; r++) {
      if (!mu[r]) {
        continue;
      }
      int dd = r * d;
      for (int i = 1; i * dd < 2 * n; i++) {
        int cur = (i - 1) / 2;
        if (i * dd >= n) {
          int j = i - (n + dd - 1) / dd;
          cur -= j;
        }
        cnt[i * r] += mu[r] * cur;
      }
    }
    for (int i = 2; i * d < 2 * n; i++) {
      int cur;
      if (i * d - d <= n) {
        cur = pk[d];
      } else {
        cur = pk[i * d - n];
      }
      cur = mul(cur, mul(2, cnt[i]));
      add(res, cur);
    }
  }
  int rk = inv(k);
  for (int i = 0; i < n; i++) {
    res = mul(res, rk);
  }
  printf("%d\n", res);
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

You are given integers n, k. Let's consider the alphabet consisting of k different elements.

Let beauty f(s) of the string s be the number of indexes i, 1≤ i<|s|, for which prefix of s of length i equals to suffix of s of length i. For example, beauty of the string abacaba equals 2, as for i = 1, 3 prefix and suffix of length i are equal.

Consider all words of length n in the given alphabet. Find the expected value of f(s)^2 of a uniformly chosen at random word. We can show that it can be expressed as P/Q, where P and Q are coprime and Q isn't divided by 10^9 + 7. Output P⋅ Q^{-1} mod 10^9 + 7.

Input

The first and the only line contains two integers n, k (1≤ n ≤ 10^5, 1≤ k≤ 10^9) — the length of a string and the size of alphabet respectively.

Output

Output a single integer — P× Q^{-1} mod 10^9 + 7.

Examples

Input


2 3


Output


333333336


Input


1 5


Output


0


Input


100 1


Output


9801


Input


10 10


Output


412377396

Note

In the first example, there are 9 words of length 2 in alphabet of size 3 — aa, ab, ac, ba, bb, bc, ca, cb, cc. 3 of them have beauty 1 and 6 of them have beauty 0, so the average value is 1/3.

In the third example, there is only one such word, and it has beauty 99, so the average value is 99^2.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const long long infll = (long long)1.01e18;
const long double eps = 1e-9;
const long double pi = acos((long double)-1);
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x) { return mrand() % x; }
const int mod = (int)1e9 + 7;
int mul(int a, int b) { return (long long)a * b % mod; }
void add(int &a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
const int maxn = (int)1e5 + 5;
int lDiv[maxn];
vector<int> pr;
int mu[maxn];
void precalc() {
  for (int i = 2; i < maxn; i++) {
    if (!lDiv[i]) {
      lDiv[i] = i;
      pr.push_back(i);
    }
    for (int j = 0; j < ((int)(pr).size()) && pr[j] <= lDiv[i]; j++) {
      int p = pr[j] * i;
      if (p >= maxn) {
        break;
      }
      lDiv[p] = pr[j];
    }
  }
  mu[1] = 1;
  for (int i = 2; i < maxn; i++) {
    int pi = i / lDiv[i];
    if (lDiv[pi] == lDiv[i]) {
      mu[i] = 0;
      continue;
    }
    mu[i] = -mu[pi];
  }
}
pair<int, int> gcd(int a, int b) {
  if (!b) {
    return make_pair(1, 0);
  }
  pair<int, int> p = gcd(b, a % b);
  return make_pair(p.second, p.first - (a / b) * p.second);
}
int inv(int x) {
  int res = gcd(x, mod).first;
  return (res % mod + mod) % mod;
}
int n, k;
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return false;
  }
  return true;
}
int pk[maxn];
int cnt[2 * maxn];
void solve() {
  pk[0] = 1;
  for (int i = 1; i < maxn; i++) {
    pk[i] = mul(pk[i - 1], k);
  }
  int res = 0;
  for (int i = 1; i < n; i++) {
    add(res, pk[n - i]);
  }
  for (int d = 1; d < n; d++) {
    for (int i = 1; i * d < 2 * n; i++) {
      cnt[i] = (i - 1) / 2;
      if (i * d >= n) {
        int j = i - (n + d - 1) / d;
        cnt[i] -= j;
      }
    }
    for (int r = 2; r * d < n; r++) {
      if (!mu[r]) {
        continue;
      }
      int dd = r * d;
      for (int i = 1; i * dd < 2 * n; i++) {
        int cur = (i - 1) / 2;
        if (i * dd >= n) {
          int j = i - (n + dd - 1) / dd;
          cur -= j;
        }
        cnt[i * r] += mu[r] * cur;
      }
    }
    for (int i = 2; i * d < 2 * n; i++) {
      int cur;
      if (i * d - d <= n) {
        cur = pk[d];
      } else {
        cur = pk[i * d - n];
      }
      cur = mul(cur, mul(2, cnt[i]));
      add(res, cur);
    }
  }
  int rk = inv(k);
  for (int i = 0; i < n; i++) {
    res = mul(res, rk);
  }
  printf("%d\n", res);
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}

```