#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MAXN = 100000;
const int MAXM = 100000;
const int K = 17;
const int mod = 1000000007;


vector<vector<int>> divs(MAXN+1);
vector<vector<vector<int>>> F_by_n_k(MAXN+1, vector<vector<int>>(K+1));
int ways[MAXN+1][K+1];
int C[MAXM+1][K+1];

int main() {
    for (int i=1; i<=MAXN; i++) {
        for (int j=i; j<=MAXN; j+=i) {
            divs[j].push_back(i);
        }
    }

    ways[1][0] = 1;
    for (int k=1; k<=K; k++) {
        ways[1][k] = 0;
    }

    for (int n=2; n<=MAXN; n++) {
        for (int k=0; k<=K; k++) {
            if (k==0) {
                F_by_n_k[n][k] = vector<int>(divs[n].size(), 0);
                auto it = lower_bound(divs[n].begin(), divs[n].end(), 2);
                if (it != divs[n].end()) {
                    int idx = it - divs[n].begin();
                    ways[n][k] = F_by_n_k[n][k][idx];
                } else {
                    ways[n][k] = 0;
                }
                continue;
            }

            int len = divs[n].size();
            vector<int> F_vec(len, 0);
            for (int i = len-1; i>=0; i--) {
                int d = divs[n][i];
                int j = n / d;
                long long ways_temp = 0;

                if (j == 1) {
                    if (k-1 == 0) {
                        ways_temp = 1;
                    }
                } else if (j <= MAXN && j >= 1 && k-1 >= 0) {
                    vector<int> &div_j = divs[j];
                    auto it_j = lower_bound(div_j.begin(), div_j.end(), d);
                    if (it_j != div_j.end()) {
                        int idx_j = it_j - div_j.begin();
                        ways_temp = F_by_n_k[j][k-1][idx_j];
                    }
                }

                int next_F = 0;
                if (i+1 < len) {
                    next_F = F_vec[i+1];
                }
                F_vec[i] = (next_F + ways_temp) % mod;
            }

            auto it = lower_bound(divs[n].begin(), divs[n].end(), 2);
            if (it != divs[n].end()) {
                int idx = it - divs[n].begin();
                ways[n][k] = F_vec[idx];
            } else {
                ways[n][k] = 0;
            }
            F_by_n_k[n][k] = F_vec;
        }
    }

    for (int i=0; i<=MAXM; i++) {
        C[i][0] = 1;
        if (i <= K) {
            for (int j=1; j<=i && j<=K; j++) {
                if (j == i) {
                    C[i][j] = 1;
                } else {
                    C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
                }
            }
        } else {
            for (int j=1; j<=K; j++) {
                C[i][j] = (C[i-1][j] + C[i-1][j-1]) % mod;
            }
        }
    }

    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int n, m;
        cin >> n >> m;
        long long ans = 0;
        int max_k = min(m, K);
        for (int k=0; k<=max_k; k++) {
            ans = (ans + 1LL * C[m][k] * ways[n][k]) % mod;
        }
        cout << ans << '\n';
    }
    return 0;
}