N = int(input()) s = 0 for i in range(N): c, d = map(int, input().split()) s += (c + 1) // 2 * d print(s % (10**9 + 7))