#include using namespace std; int main() { int q; cin >> q; for (int _ = 0; _ < q; _++) { int64_t n, k; cin >> n >> k; if (k == 1) { cout << n - 1 << endl; continue; } int64_t ans = 0; for (int64_t tmp = 1; tmp < n; tmp *= k) { ans++; } cout << ans << endl; } return 0; }