N = int(input()) cnt = 0 mod = int(1E9+7) for i in range(N): C, D = map(int, input().split(' ')) C = (C + 1) // 2 % mod D %= mod cnt += C * D cnt %= mod print(int(cnt))