#include using namespace std; using i64 = long long; int main() { cin.tie(0); std::ios::sync_with_stdio(false); i64 Q; cin >> Q; for(i64 i = 0;i < Q;i++) { i64 N, K; cin >> N >> K; i64 depth = 0; i64 now = 1; i64 cnt = 1; if(K == 1) { cout << N - 1 << endl; continue; } while(cnt < N) { now *= K; cnt += now; depth++; } cout << depth << endl; } }