#include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; int main() { int n; cin >> n; vector c(n),d(n); rep(i,n) { cin >> c[i] >> d[i]; } ll ans = 0; rep(i,n) { ll ret = c[i]/2 + c[i]%2; ans %= MOD; ret *= d[i]; ret %= MOD; ans += ret; ans %= MOD; } cout << ans << endl; return 0; }