#include using namespace std; typedef long long ll; int main() { int q; cin >> q; while (q--) { ll n, k; cin >> n >> k; if (k == 1) { cout << n - 1 << '\n'; } else { ll cur = 1; int ans = 0; while (cur < n) { cur *= k; ans++; } cout << ans << '\n'; } } return 0; }