#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; ll ans = N / sh; ll now = 1000; while (now < 1e15) { if (now <= N && now % sh != 0) ans++; now *= 10; } cout << ans << endl; } }