#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 << ceil(pow(n, 1./k)) << endl; else cout << n - 1 << endl; } }