#include <bits/stdc++.h>
using namespace std;
struct node {
  int nxt, t;
} A[1166900];
int head[100010], node_cnt;
void add_edge(int x, int y) {
  A[node_cnt] = (node){head[x], y};
  head[x] = node_cnt++;
}
int pri[100010], pri_cnt, mu[100010];
bool mark[100010];
void sieve() {
  int i, j;
  mu[1] = 1;
  for (i = 2; i < 100010; i++) {
    if (!mark[i]) {
      pri[++pri_cnt] = i;
      mu[i] = -1;
    }
    for (j = 1; j <= pri_cnt; j++) {
      int t = i * pri[j];
      if (t >= 100010) {
        break;
      }
      mark[t] = 1;
      if ((i % pri[j]) == 0) {
        mu[t] = 0;
        break;
      }
      mu[t] = -mu[i];
    }
  }
  memset(head, -1, sizeof(head));
  for (i = 100010 - 1; i >= 1; i--) {
    for (j = i; j < 100010; j += i) {
      add_edge(j, i);
    }
  }
}
int Fac[100010], Inv[100010], InvFac[100010];
void init() {
  sieve();
  int i;
  Fac[0] = 1;
  for (i = 1; i < 100010; i++) {
    Fac[i] = 1LL * Fac[i - 1] * i % 1000000007;
  }
  Inv[1] = 1;
  for (i = 2; i < 100010; i++) {
    Inv[i] =
        1LL * (1000000007 - 1000000007 / i) * Inv[1000000007 % i] % 1000000007;
  }
  InvFac[0] = 1;
  for (i = 1; i < 100010; i++) {
    InvFac[i] = 1LL * InvFac[i - 1] * Inv[i] % 1000000007;
  }
}
int C(int n, int m) {
  if (n < m) {
    return 0;
  }
  return 1LL * Fac[n] * InvFac[n - m] % 1000000007 * InvFac[m] % 1000000007;
}
int main() {
  init();
  int Case;
  scanf("%d", &Case);
  while (Case--) {
    int i, n, m, Ans = 0;
    scanf("%d%d", &n, &m);
    for (i = head[n]; ~i; i = A[i].nxt) {
      int x = A[i].t, y = n / x;
      if (y < m) {
        break;
      }
      Ans = (Ans + mu[x] * C(y - 1, m - 1)) % 1000000007;
    }
    if (Ans < 0) {
      Ans += 1000000007;
    }
    printf("%d\n", Ans);
  }
  return 0;
}
