q=input("") while q!=0: l,c=raw_input("").split(" ") l=int(l) c=int(c) k=l-1 b=[0]*l last=l-1 first=0 m=l g=l while 1: c1=c-k k-=1 l-=1 if c1