#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); ll score=fi*1000+se; ll ans=0; for(int i=1;i<=min(N,1000ll);i++){ ll sum=score*i; if(sum/i==score&&(sum%1000<=1))ans++; } ans+=max(0ll,N-1000); cout<