#include #ifdef LOCAL #include "./debug.cpp" #else #define debug(...) #define print_line #endif using namespace std; using ll = long long; int main() { int T; cin >> T; while (T--) { ll N, fi, se; scanf("%lld %lld.%lld", &N, &fi, &se); debug(N, fi, se); if (se == 0) { cout << N << endl; continue; } if (N < 1000 && 1000 % se > 1) { cout << 0 << endl; continue; } ll sh = 1000 / se; cout << min(N, 1000ll) / sh + max(0ll, N - 1000) << endl; } }