#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, c;
  bool d = false;
  cin >> n;
  vector<vector<int>> A(n + 1);
  vector<int> B(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> p >> c;
    B[i] = c;
    if (p != -1) A[p].push_back(i);
  }
  for (int i = 1; i <= n; i++)
    if (B[i] == 1) {
      bool c = false;
      for (int u = 0; u < A[i].size(); u++)
        if (B[A[i][u]] != 1) {
          c = true;
          break;
        }
      if (!c) cout << i << ' ', d = true;
    }
  if (!d) cout << -1;
  return 0;
}
