n = int(raw_input()) ans = 0 #mod = 10**9 + 7 mod = int(1e9 + 7) for i in range(n): c, d = map(int, raw_input().split()) if c % 2 == 0: ans += (c / 2) * d else: ans += (c / 2 + 1) * d ans %= mod print int(ans)