Q=int(input()) for _ in range(Q): S,T=input().split() N=len(S) M=len(T) result=0 u=[0]*2 w='' for i in range(N): u2=[0]*2 for x in range(10): if i>=M: u2[0]+=u[0] else: y=int(T[i]) if x0: for x in range(1,10): if x=M: t=T else: t=T[:i+1] if s==t: u2[1]+=1 else: L=[s,t] L.sort() if s==L[0]: u2[0]+=1 else: for x in range(1,y): if x