## https://yukicoder.me/problems/no/2017 SMALL_MOD = 7 MOD = 10 ** 9 + 7 def main(): K = int(input()) dl = [] for _ in range(K): D, L = map(int, input().split()) dl.append((D, L)) dp = [[0] * SMALL_MOD for _ in range(K + 1)] dp[0][0] = 1 for i in range(K): d, l = dl[i] pow_10_l = pow(10, l, SMALL_MOD) # dをl個並べた時の値計算 val = 0 x = d length = 1 while l > 0: y = pow(10, length, SMALL_MOD) if l % 2 == 1: val *= y val %= SMALL_MOD val += x val %= SMALL_MOD y0 = (x * y) % SMALL_MOD x = (y0 + x) % SMALL_MOD length *= 2 l //= 2 for j in range(SMALL_MOD): dp[i + 1][j] += dp[i][j] dp[i + 1][j] %= MOD new_j = j * pow_10_l new_j %= SMALL_MOD new_j += val new_j %= SMALL_MOD dp[i + 1][new_j] += dp[i][j] dp[i + 1][new_j] %= MOD answer = 0 for i in range(SMALL_MOD): ans = i * dp[-1][i] ans %= MOD answer += ans answer %= MOD print(answer) if __name__ == '__main__': main()