#include #include using namespace std; int main(){ ios::sync_with_stdio(false); double n, c, d, total=0; cin >> n; for(int i=0; i> c >> d; c=ceil(c/2); total+=c*d; } total=fmod(total, pow(10, 9)+7); cout << total << "\n"; return 0; }