#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	const int mod = 1e9 + 7;  
	int n;
	cin >> n;
	long long ans = 0;
	while(n--) {
		long long c, d;
		cin >> c >> d;
		ans += (c + 1) / 2 % mod * (d % mod) % mod;
	}
	cout << ans % mod << endl;
	return 0;	
}