#include using namespace std; typedef long long ll; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int q; cin>>q; while(q--){ int n,k; cin>>n>>k; n--; int ans = 0; if(k==1){ cout << n << endl; continue; } while(n){ ans++; n/=k; } cout << ans << endl; } }