#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int p[n + 1], f[n + 1], root;
  vector<int> child[n + 1];
  for (int i = 1; i <= n; i++) {
    int pa, fl;
    cin >> pa >> fl;
    if (pa == -1)
      root = i;
    else {
      p[i] = pa;
      child[pa].push_back(i);
      f[i] = fl;
    }
  }
  int flag = -1;
  for (int i = 1; i <= n; i++) {
    if (i != root) {
      if (f[i] == 1) {
        int j = 0;
        for (j = 0; j < child[i].size(); j++) {
          if (f[child[i][j]] == 0) {
            break;
          }
        }
        if (j == child[i].size()) {
          cout << i << " ";
          flag = 1;
        }
      }
    }
  }
  if (flag == -1) cout << -1;
  cout << endl;
}
