#include <bits/stdc++.h>
using namespace std;
long n, p, c, root;
long res[100000 + 5];
vector<long> ans;
vector<long> edge[100000 + 5];
void search(long x) {
  bool flag, flag2;
  flag = true;
  if (res[x] == 0) flag = false;
  flag2 = true;
  for (auto &i : edge[x]) {
    if (res[i] == 0) flag = false;
    search(i);
  }
  if ((x != root) && (flag)) ans.push_back(x);
  return;
}
int main() {
  cin >> n;
  for (long i = 1; i <= n; i++) {
    cin >> p >> c;
    if (p == -1)
      root = i;
    else {
      edge[p].push_back(i);
      res[i] = c;
    }
  }
  search(root);
  if (ans.size() == 0) {
    cout << "-1" << endl;
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (auto &i : ans) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
