#include using namespace std; using ll = long long; using P = pair; #define rep(i,n) for(int i=0;i> n; ll ans = 0l; rep(i,n){ ll c,d; cin >> c >> d; d %= mod; ll res = (c+1)/2; res %= mod; ans += res * d; ans %= mod; } cout << ans << endl; return 0; }