#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, c[200003], d[200003], sum[200003];
  int maxDiv2Idx = -1, minDiv1Idx = -1;
  bool flag = true;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> c[i] >> d[i], flag &= (d[i] == 1);
  if (flag) {
    cout << "Infinity";
    return 0;
  }
  sum[0] = 0;
  maxDiv2Idx = ((d[0] == 2) ? sum[0] : -1);
  minDiv1Idx = ((d[0] == 1) ? sum[0] : -1);
  for (int i = 1; i < n; ++i) {
    sum[i] = sum[i - 1] + c[i - 1];
    if (d[i] == 2 && (maxDiv2Idx == -1 || sum[i] > sum[maxDiv2Idx]))
      maxDiv2Idx = i;
    else if (d[i] == 1 && (minDiv1Idx == -1 || sum[i] < sum[minDiv1Idx]))
      minDiv1Idx = i;
  }
  if (minDiv1Idx != -1 && maxDiv2Idx != -1 &&
      sum[minDiv1Idx] <= sum[maxDiv2Idx]) {
    cout << "Impossible";
    return 0;
  }
  cout << (1899 - sum[maxDiv2Idx] + sum[n - 1] + c[n - 1]);
  return 0;
}
