n = int(input()) x = 0 for _ in range(n): c, d = map(int, input().split()) x += (c+1)//2 * d print(x % (10**9+7))