M = 10**9 + 7 N = int(input()) CD = [list(map(int, input().split())) for _ in range(N)] ans = sum((c + 1) // 2 * d for c, d in CD) % M print(ans)