#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, s, d, ans = 0, a;
  cin >> n;
  for (i = 0; i < n; ++i) {
    cin >> s >> d;
    if (ans < s) {
      ans = s;
    } else {
      a = (ans - s) % d;
      ans += d - a;
    }
  }
  cout << ans;
}
