#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; typedef vector<ll> vll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<vector<ll>> vvll; const ll inf = 1e16; const ll md = 1000000007; int main() { int n; cin >> n; ll ans=0LL; rep(i,n){ ll c,d; cin>>c>>d; c=(c+1)/2%md; d%=md; ans+=c*d; ans%=md; } cout << ans << endl; return 0; }