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