mod=10**9+7 X=[0]*7 X[0]=1 for t in range(int(input())): d,l=map(int,input().split()) a=pow(10,l,7) b=((a-1)*d%7)*pow(9,5,7)%7 Y=X[:] for i in range(7): Y[(a*i+b)%7]=(Y[(a*i+b)%7]+X[i])%mod X=Y[:] print(sum([i*X[i] for i in range(7)])%mod)