N = int(raw_input()) countSum = 0 for i in xrange(N): C,D = map(long,raw_input().split()) if C % 2 == 0: countSum += (C * D) / 2 else: countSum += ((C - 1) * D) print countSum % (1000000000 + 7)