import io import sys from collections import defaultdict, deque, Counter from itertools import permutations, combinations, accumulate from heapq import heappush, heappop from bisect import bisect_right, bisect_left from math import gcd import math _INPUT = """\ 6 4 5 87.500 9 91.111 27 88.889 3141592653589 100.000 """ def input(): return sys.stdin.readline()[:-1] def solve(test): t=int(input()) for _ in range(t): N,S=input().split() N=int(N) a,b=map(int,S.split('.')) x=a*1000+b ans=0 for i in range(1,min(2000,N)+1): if i*x%1000==0 or i*x//1000