#include #define int long long using namespace std; const int MOD = 1000000007; using Graph = vector>; signed main() { int Q; cin >> Q; for( int i = 0; i < Q; i++ ){ int N, K; cin >> N >> K; if( K == 1 ){ cout << N-1 << endl; continue; } int now = 1; int cnt = 0; while( now < N ){ now *= K; cnt++; } cout << cnt << endl; } }