#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  long long cur = 0, ans = 0;
  vector<pair<int, int> > v;
  for (int i = int(0); i < int(n); ++i) {
    long long ss, dd;
    cin >> ss >> dd;
    v.push_back(pair<int, int>(ss, dd));
  }
  ans = v[0].first;
  for (int i = int(1); i < int(n); ++i) {
    cur = ans;
    cur -= v[i].first;
    if (cur < 0)
      cur = v[i].first;
    else
      cur = ((cur + v[i].second - 1) / v[i].second) * v[i].second + v[i].first;
    if (cur == ans) cur += v[i].second;
    ans = cur;
  }
  cout << ans << endl;
  return 0;
}
