#include #include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; for (int i = 0; i < n; i++){ long long n, k; cin >> n >> k; if (n <= k) cout << 1 << endl; else if (k == 1) cout << n - 1 << endl; else { for (int j = 2; j < 32; j++){ if (pow(k, j) >= n){ cout << j << endl; break; } } } } }