s = 0 for _ in range(int(input())): a,b = map(int,input().split()) s += ((a+1)//2*b%(10**9+7)) s %= 10**9+7 print(s)