#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010, MAXM = 1000010;
int t, n, k, mu[MAXM], phi[MAXM];
long long sumphi[MAXM], dp[MAXM][30];
void solve(int l, int r, int xl, int xr, int k) {
  if (l > r) {
    return;
  }
  int mid = (l + r) >> 1, np = 0;
  long long nw = 0, nv = 1e18;
  for (int l = min(xr, mid - 1) + 2, r; l <= mid; l = r + 1) {
    r = mid / (mid / l);
    nw += sumphi[mid / l] * (r - l + 1);
  }
  for (int i = min(xr, mid - 1); i >= xl; i--) {
    nw += sumphi[mid / (i + 1)];
    if (dp[i][k - 1] + nw < nv) {
      nv = dp[i][k - 1] + nw;
      np = i;
    }
  }
  assert(xl <= np && np <= xr);
  dp[mid][k] = nv;
  solve(l, mid - 1, xl, np, k);
  solve(mid + 1, r, np, xr, k);
  return;
}
int main() {
  for (int i = 1; i <= MAXN - 10; i++) {
    mu[i] = 1, phi[i] = i;
    int cpi = i;
    for (int j = 2; j * j <= cpi; j++) {
      if (cpi % j == 0) {
        int cnt = 0;
        while (cpi % j == 0) {
          cpi /= j, cnt++;
        }
        if (cnt > 1) {
          mu[i] = 0;
        } else {
          mu[i] = -mu[i];
        }
        phi[i] = phi[i] / j * (j - 1);
      }
    }
    if (cpi > 1) {
      mu[i] = -mu[i], phi[i] = phi[i] / cpi * (cpi - 1);
    }
    sumphi[i] = sumphi[i - 1] + phi[i];
    dp[i][1] = 1ll * i * (i + 1) / 2;
  }
  for (int i = 2; i <= 20; i++) {
    solve(i, MAXN - 10, i - 1, MAXN - 10, i);
  }
  scanf("%d", &t);
  for (int ii = 1; ii <= t; ii++) {
    scanf("%d%d", &n, &k);
    if (k <= 20) {
      printf("%lld\n", dp[n][k]);
    } else {
      printf("%d\n", n);
    }
  }
  return 0;
}

### Prompt

Construct a CPP code solution to the problem outlined:

For two positive integers l and r (l ≤ r) let c(l, r) denote the number of integer pairs (i, j) such that l ≤ i ≤ j ≤ r and \operatorname{gcd}(i, j) ≥ l. Here, \operatorname{gcd}(i, j) is the [greatest common divisor (GCD)](https://en.wikipedia.org/wiki/Greatest_common_divisor) of integers i and j.

YouKn0wWho has two integers n and k where 1 ≤ k ≤ n. Let f(n, k) denote the minimum of ∑_{i=1}^{k}{c(x_i+1,x_{i+1})} over all integer sequences 0=x_1 < x_2 < … < x_{k} < x_{k+1}=n.

Help YouKn0wWho find f(n, k). 

Input

The first line contains a single integer t (1 ≤ t ≤ 3 ⋅ 10^5) — the number of test cases.

The first and only line of each test case contains two integers n and k (1 ≤ k ≤ n ≤ 10^5). 

Output

For each test case, print a single integer — f(n, k).

Example

Input


4
6 2
4 4
3 1
10 3


Output


8
4
6
11

Note

In the first test case, YouKn0wWho can select the sequence [0, 2, 6]. So f(6, 2) = c(1, 2) + c(3, 6) = 3 + 5 = 8 which is the minimum possible.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010, MAXM = 1000010;
int t, n, k, mu[MAXM], phi[MAXM];
long long sumphi[MAXM], dp[MAXM][30];
void solve(int l, int r, int xl, int xr, int k) {
  if (l > r) {
    return;
  }
  int mid = (l + r) >> 1, np = 0;
  long long nw = 0, nv = 1e18;
  for (int l = min(xr, mid - 1) + 2, r; l <= mid; l = r + 1) {
    r = mid / (mid / l);
    nw += sumphi[mid / l] * (r - l + 1);
  }
  for (int i = min(xr, mid - 1); i >= xl; i--) {
    nw += sumphi[mid / (i + 1)];
    if (dp[i][k - 1] + nw < nv) {
      nv = dp[i][k - 1] + nw;
      np = i;
    }
  }
  assert(xl <= np && np <= xr);
  dp[mid][k] = nv;
  solve(l, mid - 1, xl, np, k);
  solve(mid + 1, r, np, xr, k);
  return;
}
int main() {
  for (int i = 1; i <= MAXN - 10; i++) {
    mu[i] = 1, phi[i] = i;
    int cpi = i;
    for (int j = 2; j * j <= cpi; j++) {
      if (cpi % j == 0) {
        int cnt = 0;
        while (cpi % j == 0) {
          cpi /= j, cnt++;
        }
        if (cnt > 1) {
          mu[i] = 0;
        } else {
          mu[i] = -mu[i];
        }
        phi[i] = phi[i] / j * (j - 1);
      }
    }
    if (cpi > 1) {
      mu[i] = -mu[i], phi[i] = phi[i] / cpi * (cpi - 1);
    }
    sumphi[i] = sumphi[i - 1] + phi[i];
    dp[i][1] = 1ll * i * (i + 1) / 2;
  }
  for (int i = 2; i <= 20; i++) {
    solve(i, MAXN - 10, i - 1, MAXN - 10, i);
  }
  scanf("%d", &t);
  for (int ii = 1; ii <= t; ii++) {
    scanf("%d%d", &n, &k);
    if (k <= 20) {
      printf("%lld\n", dp[n][k]);
    } else {
      printf("%d\n", n);
    }
  }
  return 0;
}

```