#include <bits/stdc++.h>
using namespace std;
set<long long> candidates;
vector<long long> ans;
long long par[100004];
long long stat[100004];
long long kids[100004];
long long stats[100004];
long long pass[100004];
vector<long long> v[100004];
long long root;
long long getpar(long long x) {
  if (pass[par[x]] == 1) {
    par[x] = getpar(par[x]);
  }
  return par[x];
}
int main() {
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    long long pa, c;
    cin >> pa >> c;
    if (pa == -1) root = i;
    v[pa].push_back(i);
    stat[i] = c;
    par[i] = pa;
    kids[pa]++;
    if (c == 1) stats[pa]++;
  }
  for (int i = 1; i <= n; i++) {
    if (i == root) continue;
    if (stat[i] == 1 && stats[i] == kids[i]) {
      candidates.insert(i);
    }
  }
  while (!candidates.empty()) {
    long long temp = *candidates.begin();
    candidates.erase(candidates.begin());
    pass[temp] = 1;
    ans.push_back(temp);
    long long pa = getpar(par[temp]);
    kids[pa] += kids[temp];
    stats[pa] += stats[temp];
    if (pa == root) continue;
    if (stat[pa] == 1 && stats[pa] == kids[pa]) candidates.insert(pa);
  }
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << " ";
  }
  if (ans.size() == 0) {
    cout << -1;
  }
  cout << endl;
  return 0;
}
