#include using namespace std; using ll = long long; int main(){ int T; cin >> T; while(T--){ ll n, s0, s1, s = 0; scanf("%lld %lld.%lld", &n, &s0, &s1); s = s0 * 1000 + s1; ll ans = 0, c = min(n, 1000ll); ans += max(0ll, n - 1000); for(ll i = 1; i <= c; i++){ for(ll j = s0 * i; j <= (s0 + 1) * i; j++){ if((j * 1000) / i == s){ ans++; break; } } } cout << ans << '\n'; } }