#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, a, b, i, f = 0;
  vector<int> v;
  map<int, int> m;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    if (b == 1)
      v.push_back(i + 1);
    else
      m[a] = 1;
  }
  for (int i : v) {
    if (!m[i]) {
      cout << i << " ";
      f = 1;
    }
  }
  if (!f) cout << -1;
}
