#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  int n, a, b;
  cin >> n;
  bool visit[1000005] = {false};
  int ans = -1;
  while (n--) {
    cin >> a >> b;
    while (visit[a] || a < ans) {
      a += b;
    }
    ans = max(ans, a);
    visit[a] = true;
  }
  cout << ans;
  return 0;
}
