#include using namespace std; int depth(int n, int k) { if (k == 1) return n - 1; int s = 1, p = k, d = 0; while (s < n) { s += p; p *= k; d++; } return d; } int main() { int q; cin >> q; for (int i = 0; i < q; i++) { int n, k; cin >> n >> k; cout << depth(n, k) << endl; } }