#include <bits/stdc++.h>
using namespace std;
int n;
int p[100002];
bool c[100002];
vector<int> ch[100002];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    ch[p[i]].push_back(i);
  }
  bool none = true;
  for (int i = 1; i <= n; i++) {
    if (c[i]) {
      bool r = true;
      for (int j : ch[i]) {
        if (!c[j]) r = false;
      }
      if (r) {
        cout << i << " ";
        none = false;
        for (int j : ch[i]) {
          p[j] = p[i];
        }
      }
    }
  }
  if (none) cout << "-1";
}
