#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int c[maxn], p[maxn];
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  fill(c, c + maxn, -1);
  set<int> s;
  for (int i = 1; i <= n; i++) {
    s.insert(i);
    cin >> p[i] >> c[i];
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] == 0) {
      s.erase(p[i]);
      s.erase(i);
    }
  }
  for (auto x : s) {
    cout << x << " ";
  }
  if (s.empty()) cout << -1;
  return 0;
}
