n = int(input()) desk_data = list() for i in range(n): desk_data.append(tuple(map(int, input().split()))) people = 0 for num_chair, num_desk in desk_data: people += num_desk*(num_chair//2 + num_chair%2) print(people%(10**9+7))