#include using namespace std; #define int long long signed main(){ int q; cin >> q; while(q--){ int n, k; cin >> n >> k; int ans = 0; int now = k; int num = 1; if(k == 1){ cout << n-1 << endl; continue; } while(num < n){ num += now; ans++; now *= k; } cout << ans << endl; } return 0; }