#include <bits/stdc++.h>   using namespace std;   const int maxn = 100007;   const int maxv = 100000;   long long fac[maxn], fac2[maxn];   map<pair<int, int>, int> save;   int cnt;   long long mypow(int base, int n) {     if (n == 0) return 1;     long long t = mypow(base, n / 2);     t = (t * t) % 1000000007;     if (n & 1)       return (t * base) % 1000000007;     else       return t;   }   long long C(int n, int k) {     long long res = fac[n] * fac2[k] % 1000000007;     res = res * fac2[n - k] % 1000000007;     return res;   }   long long solve(int f, int n) {     if (f == 1) return (n == 1);     if (f == n) return 1;     if (f > n) return 0;     if (save.count(pair<int, int>(f, n))) return save[pair<int, int>(f, n)];     long long res = 0;     for (int i = 2; i * i <= n; i++)       if (n % i == 0) {         int x = i;         res = (res + solve(f, n / x)) % 1000000007;         if (i * i == n) continue;         x = n / i;         res = (res + solve(f, n / x)) % 1000000007;       }     save[pair<int, int>(f, n)] =         (C(n - 1, f - 1) - res + 1000000007) % 1000000007;     return save[pair<int, int>(f, n)];   }   int main() {     fac[0] = 1;     for (int i = 1, _c = maxv; i <= _c; i++) fac[i] = fac[i - 1] * i % 1000000007;     for (int v = 0, _c = maxv; v <= _c; v++)       fac2[v] = mypow(fac[v], 1000000007 - 2);     int q, f, n;     scanf( %d , &q);     for (int i = 0, _a = (q); i < _a; ++i) {       scanf( %d%d , &n, &f);       printf( %I64d n , solve(f, n));     }   }   