#include using namespace std; using lint = long long int; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i> Q; REP(_, Q) { cin >> N >> K; lint ret = 0, a = 1; while (a < N) ret++, a = a * K + 1; cout << ret << endl; } }