#include using namespace std; #define int long long #define all(x) x.begin(), x.end() #define app push_back #ifdef LOCAL #define debug(...) [](auto...a){ ((cout << a << ' '), ...) << '\n';}(#__VA_ARGS__, ":", __VA_ARGS__) #else #define debug(...) #endif int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int t;cin>>t; while(t--) { int n;string s;cin>>n>>s; s.erase(find(all(s),'.'));int s1=stoi(s); int res=0; for(int i=1;i<=1000 && i<=n;++i) { int low=s1*i; int up=(s1+1)*i; //debug(low,up); bool ok=0; if((up-1)/1000>(low-1)/1000) { ok=1; } res+=ok; } res+=max(0LL,n-1000); cout<