#include <bits/stdc++.h>
using namespace std;
void deleteNodes(int *nodes, int count, bool *resp) {
  int *del = new int[count];
  for (int i = 0; i < count; ++i) {
    del[i] = 1;
  }
  for (int i = 1; i < count; ++i) {
    if (resp[i]) {
      del[nodes[i]] = 0;
      del[i] = 0;
    } else {
      del[nodes[i]] &= 1;
    }
  }
  bool found = false;
  for (int i = 1; i < count; ++i) {
    if (del[i]) {
      found = true;
      cout << i << " ";
    }
  }
  if (!found) {
    cout << -1;
  }
  delete[] del;
}
int main() {
  int n;
  cin >> n;
  int *nodes = new int[n + 1];
  bool *resp = new bool[n + 1];
  for (int i = 1; i <= n; ++i) {
    int p, c;
    cin >> p >> c;
    if (p == -1) {
      nodes[i] = 0;
    } else {
      nodes[i] = p;
    }
    resp[i] = c == 0;
  }
  deleteNodes(nodes, n + 1, resp);
  delete[] nodes;
  delete[] resp;
}
