Today is Devu's birthday. For celebrating the occasion, he bought n sweets from the nearby market. He has invited his f friends. He would like to distribute the sweets among them. As he is a nice guy and the occasion is great, he doesn't want any friend to be sad, so he would ensure to give at least one sweet to each friend. 

He wants to celebrate it in a unique style, so he would like to ensure following condition for the distribution of sweets. Assume that he has distributed n sweets to his friends such that ith friend is given ai sweets. He wants to make sure that there should not be any positive integer x > 1, which divides every ai.

Please find the number of ways he can distribute sweets to his friends in the required way. Note that the order of distribution is important, for example [1, 2] and [2, 1] are distinct distributions. As the answer could be very large, output answer modulo 1000000007 (109 + 7).

To make the problem more interesting, you are given q queries. Each query contains an n, f pair. For each query please output the required number of ways modulo 1000000007 (109 + 7).

Input

The first line contains an integer q representing the number of queries (1 ≤ q ≤ 105). Each of the next q lines contains two space space-separated integers n, f (1 ≤ f ≤ n ≤ 105).

Output

For each query, output a single integer in a line corresponding to the answer of each query.

Examples

Input

5
6 2
7 2
6 3
6 4
7 4


Output

2
6
9
10
20

Note

For first query: n = 6, f = 2. Possible partitions are [1, 5] and [5, 1].

For second query: n = 7, f = 2. Possible partitions are [1, 6] and [2, 5] and [3, 4] and [4, 3] and [5, 3] and [6, 1]. So in total there are 6 possible ways of partitioning.
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
using namespace std;
double __begin;
template <typename T1, typename T2, typename T3>
struct triple {
  T1 a;
  T2 b;
  T3 c;
  triple(){};
  triple(T1 _a, T2 _b, T3 _c) : a(_a), b(_b), c(_c) {}
};
template <typename T1, typename T2, typename T3>
bool operator<(const triple<T1, T2, T3> &t1, const triple<T1, T2, T3> &t2) {
  if (t1.a != t2.a)
    return t1.a < t2.a;
  else
    return t1.b < t2.b;
}
template <typename T1, typename T2, typename T3>
inline std::ostream &operator<<(std::ostream &os, const triple<T1, T2, T3> &t) {
  return os << "(" << t.a << ", " << t.b << ", " << t.c << ")";
}
inline int bits_count(int v) {
  v = v - ((v >> 1) & 0x55555555);
  v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
  return ((v + (v >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
inline int bits_count(long long v) {
  int t = v >> 32;
  int p = (v & ((1LL << 32) - 1));
  return bits_count(t) + bits_count(p);
}
unsigned int reverse_bits(register unsigned int x) {
  x = (((x & 0xaaaaaaaa) >> 1) | ((x & 0x55555555) << 1));
  x = (((x & 0xcccccccc) >> 2) | ((x & 0x33333333) << 2));
  x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
  x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
  return ((x >> 16) | (x << 16));
}
inline int sign(int x) { return (x >> 31) | (-x >> 31); }
inline bool ispow2(int x) { return (x != 0 && (x & (x - 1)) == 0); }
template <typename T1, typename T2>
inline std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
inline std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
  bool first = true;
  os << "[";
  for (unsigned int i = 0; i < v.size(); i++) {
    if (!first) os << ", ";
    os << v[i];
    first = false;
  }
  return os << "]";
}
template <typename T>
inline std::ostream &operator<<(std::ostream &os, const std::set<T> &v) {
  bool first = true;
  os << "[";
  for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
template <typename T1, typename T2>
inline std::ostream &operator<<(std::ostream &os, const std::map<T1, T2> &v) {
  bool first = true;
  os << "[";
  for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end();
       ++ii) {
    if (!first) os << ", ";
    os << *ii;
    first = false;
  }
  return os << "]";
}
template <typename T, typename T2>
void printarray(T a[], T2 sz, T2 beg = 0) {
  for (T2 i = beg; i < sz; i++) cout << a[i] << " ";
  cout << endl;
}
inline long long binpow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res *= x;
    x *= x;
    n >>= 1;
  }
  return res;
}
inline long long powmod(long long x, long long n, long long _mod) {
  long long res = 1;
  while (n) {
    if (n & 1) res = (res * x) % _mod;
    x = (x * x) % _mod;
    n >>= 1;
  }
  return res;
}
inline long long gcd(long long a, long long b) {
  long long t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline int gcd(int a, int b) {
  int t;
  while (b) {
    a = a % b;
    t = a;
    a = b;
    b = t;
  }
  return a;
}
inline long long lcm(int a, int b) { return a / gcd(a, b) * (long long)b; }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long gcd(long long a, long long b, long long c) {
  return gcd(gcd(a, b), c);
}
inline int gcd(int a, int b, int c) { return gcd(gcd(a, b), c); }
inline long long lcm(long long a, long long b, long long c) {
  return lcm(lcm(a, b), c);
}
inline long long lcm(int a, int b, int c) {
  return lcm(lcm(a, b), (long long)c);
}
inline long long max(long long a, long long b) { return (a > b) ? a : b; }
inline int max(int a, int b) { return (a > b) ? a : b; }
inline double max(double a, double b) { return (a > b) ? a : b; }
inline long long max(long long a, long long b, long long c) {
  return max(a, max(b, c));
}
inline int max(int a, int b, int c) { return max(a, max(b, c)); }
inline double max(double a, double b, double c) { return max(a, max(b, c)); }
inline long long min(long long a, long long b) { return (a < b) ? a : b; }
inline int min(int a, int b) { return (a < b) ? a : b; }
inline double min(double a, double b) { return (a < b) ? a : b; }
inline long long min(long long a, long long b, long long c) {
  return min(a, min(b, c));
}
inline int min(int a, int b, int c) { return min(a, min(b, c)); }
inline double min(double a, double b, double c) { return min(a, min(b, c)); }
template <class T>
inline void getar(T a, int n, int m) {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; ++j) {
      scanf("%d", &a[i][j]);
    }
}
inline void getar(int *a, int n) {
  for (int ii = 0; ii < n; ii++) {
    scanf("%d", a + ii);
  }
}
inline void getar(pair<int, int> *a, int n) {
  for (int ii = 0; ii < n; ii++) {
    scanf("%d%d", &a[ii].first, &a[ii].second);
  }
}
inline void getar(long long *a, int n) {
  for (int ii = 0; ii < n; ii++) {
    scanf("%I64d", a + ii);
  }
}
int fact[100010];
int revf[100010];
bool e[100010];
int C(int n, int m) {
  if (n < m) return 0;
  return (((fact[n] * 1ll * revf[m]) % 1000000007) * revf[n - m]) % 1000000007;
}
vector<int> divs[100010];
map<pair<int, int>, int> m;
int prime[100010];
vector<int> primes;
void prime_sieve(int n) {
  int t = (n * 1.2) / log(1.0 * n);
  primes.reserve(n < 5000 ? 1000 : t);
  for (int i = 2; i <= n; ++i) {
    if (prime[i] == 0) {
      primes.push_back(i);
      prime[i] = i;
    }
    for (int j = 0;
         j < primes.size() && i * primes[j] <= n && primes[j] <= prime[i];
         ++j) {
      prime[i * primes[j]] = primes[j];
    }
  }
}
int foo(int n, int f) { return (fact[n - 1] * 1ll * revf[n - f]) % 1000000007; }
int powmod(long long x) {
  int n = 1000000007 - 2;
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = (res * x) % 1000000007;
    }
    x = (x * x) % 1000000007;
    n >>= 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  prime_sieve(100000);
  fact[0] = 1;
  revf[0] = 1;
  for (int i = 1; i <= 100000; ++i) {
    fact[i] = (fact[i - 1] * 1ll * i) % 1000000007;
    revf[i] = powmod(fact[i]);
  }
  for (int i = 2; i <= 100000; ++i) {
    e[i] = !e[i / prime[i]];
    if (prime[i] != i) {
      int p = prime[i];
      int t = i / p;
      if (p == prime[t]) {
        divs[i] = divs[t];
      } else {
        divs[i].reserve(divs[t].size() * 2 + 1);
        divs[i].push_back(p);
        for (int d : divs[t]) {
          divs[i].push_back(d);
          divs[i].push_back(d * p);
        }
      }
    } else {
      divs[i].push_back(i);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int f, n;
    cin >> n >> f;
    if (f == 1) {
      cout << (n == 1) << '\n';
      continue;
    }
    int ans = foo(n, f);
    for (int p : divs[n]) {
      if (p == n) continue;
      int q = n / p;
      if (q < f) continue;
      int t = foo(q, f);
      if (e[p]) {
        ans -= t;
        if (ans < 0) ans += 1000000007;
      } else {
        ans += t;
        if (ans >= 1000000007) ans -= 1000000007;
      }
    }
    ans = (ans * 1ll * revf[f - 1]) % 1000000007;
    cout << ans << '\n';
  }
  return 0;
}
