#include <bits/stdc++.h>
using namespace std;
int n, c[100001], tat[100001];
vector<int> G[100001];
set<int> mySet;
int root;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> tat[i] >> c[i];
    if (tat[i] == -1)
      root = i;
    else {
      G[tat[i]].push_back(i);
    }
  }
  for (int i = 1; i <= n; ++i)
    if (i != root) {
      int fii = 0;
      for (vector<int>::iterator it = G[i].begin(); it != G[i].end(); ++it) {
        if (c[*it] == 1) {
          fii++;
        }
      }
      if (c[i] == 1 && fii == G[i].size()) mySet.insert(i);
    }
  if (mySet.size() == 0) {
    cout << -1;
    return 0;
  }
  while (!mySet.empty()) {
    cout << *mySet.begin() << ' ';
    int care = *mySet.begin();
    mySet.erase(care);
    for (vector<int>::iterator it = G[care].begin(); it != G[care].end();
         ++it) {
      tat[*it] = tat[care];
      if (c[*it] == 0) mySet.erase(tat[care]);
    }
  }
}
