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