#include using namespace std; int main() { int n, ans = 0; auto mod = [](long long x){return x % 1000000007;}; cin >> n; for (int i = 0; i < n; i++) { long long c, d; cin >> c >> d; c = mod((c+1)/2); d = mod(d); ans = mod(ans + c * d); } cout << ans << endl; return 0; }