ctr = 0
minsum = 0
t = int(input())
while(t<=ctr):
    minsum = 5001
    n = int(input())
    for i in range(n):
        m,p = int(input()).split()
        s = (p*n)//(m+1)
        if(s<minsum):
            minsum = s
    print(minsum)
    