#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int di[maxn][300];
int usado, mk[maxn];
long long fa[maxn];
long long in[maxn];
long long dp[maxn];
int cont[maxn];
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2) return (power(a, b - 1) * a) % 1000000007;
  long long t = power(a, b / 2);
  return (t * t) % 1000000007;
}
long long F(int n, int f) {
  if (n == f) return 1;
  if (n < f) return 0;
  if (mk[n] == usado) return dp[n];
  long long ans = 0;
  mk[n] = usado;
  for (int i = 1; i <= cont[n]; i++) {
    int x = di[n][i];
    ans = (ans + F(n / x, f)) % 1000000007;
  }
  return dp[n] = ans =
             (((((fa[n - 1] * in[n - 1 - f + 1]) % 1000000007) * in[f - 1]) %
               1000000007) +
              1000000007 - ans) %
             1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 2; i <= maxn - 5; i++) {
    for (int j = i; j <= maxn - 5; j += i) {
      cont[j]++;
      di[j][cont[j]] = i;
    }
  }
  fa[0] = 1;
  in[0] = power(1, 1000000007 - 2);
  for (int i = 1; i <= 100000; i++) {
    fa[i] = (fa[i - 1] * i) % 1000000007;
    in[i] = power(fa[i], 1000000007 - 2);
  }
  int q;
  cin >> q;
  int n, f;
  while (q--) {
    cin >> n >> f;
    usado++;
    cout << F(n, f) << '\n';
  }
  return 0;
}
