#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v(n + 1, 0);
  vector<vector<int> > g(n + 1);
  int i, j, k;
  for (i = 1; i <= n; i++) {
    cin >> j >> k;
    v[i] = k;
    if (j != -1) {
      g[j].push_back(i);
    }
  }
  vector<int> ans;
  for (i = 1; i <= n; i++) {
    if (v[i] == 1) {
      int kk = 1;
      for (j = 0; j < g[i].size(); j++) {
        if (v[g[i][j]] == 0) kk = 0;
      }
      if (kk) ans.push_back(i);
    }
  }
  sort(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  if (ans.size() == 0) cout << -1;
}
