K = int(input()) D = [0]*K L = [0]*K for i in range(K): D[i],L[i] = map(int,input().split()) mod = int(1e9+7) div = pow(9,5,7) dp = [[0]*7 for i in range(7)] dp[0][1] = 1 for i in reversed(range(K)): mem = pow(10,L[i],7) cp = [[0]*7 for i in range(7)] for j in range(7): for k in range(7): cp[j][k] += dp[j][k] cp[j][k] %= mod S = (mem*k-k)*div*D[i]+j S %= 7 T = mem*k%7 cp[S][T] += dp[j][k] cp[S][T] %= mod dp = cp ans = 0 for i in range(7): for j in range(7): ans += dp[i][j]*i ans %= mod print(ans)