#include <bits/stdc++.h>
using namespace std;
vector<int> tree[100005];
vector<int> bedeleted;
bool visited[100005];
bool c[100005];
int count1;
int respect;
void DFS(int source) {
  visited[source] = true;
  int s = tree[source].size();
  if (c[source] == 1) {
    bool f = 0;
    for (int i = 0; i < s; ++i) {
      if (c[tree[source][i]] == 0) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      bedeleted.push_back(source);
    }
  }
  for (int i = 0; i < s; ++i) {
    if (visited[tree[source][i]] == false) {
      DFS(tree[source][i]);
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int source;
  int n;
  cin >> n;
  int inp;
  for (int i = 1; i <= n; ++i) {
    cin >> inp;
    cin >> c[i];
    if (inp != -1) tree[inp].push_back(i);
    if (inp == -1) {
      source = i;
      c[i] = 0;
    }
  }
  DFS(source);
  if (bedeleted.size() == 0)
    cout << -1;
  else {
    sort(bedeleted.begin(), bedeleted.end());
    for (auto x = bedeleted.begin(); x != bedeleted.end(); ++x) {
      cout << *x << " ";
    }
  }
  return 0;
}
