#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  char ar[n];
  vector<vector<int>> v(n);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b == 1)
      ar[i] = '1';
    else
      ar[i] = '0';
    if (a != -1) v[a - 1].push_back(i);
  }
  int flag1 = 0;
  for (int i = 0; i < n; i++) {
    if (ar[i] == '1') {
      int flag = 0;
      for (int j = 0; j < v[i].size(); j++) {
        if (ar[v[i][j]] == '0') {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        cout << i + 1 << " ";
        flag1 = 1;
      }
    }
  }
  if (flag1 == 0) cout << "-1";
  return 0;
}
