#include <bits/stdc++.h>
using namespace std;
int c[100001];
vector<vector<int>> a(100001);
vector<int> meh;
void dfs(int k, int t) {
  int x = 0;
  for (int i = 0; i < a[k].size(); i++) {
    if (c[a[k][i]] == 0) {
      x++;
    }
    dfs(a[k][i], k);
  }
  if (!x && c[k]) meh.push_back(k);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, head;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    c[i] = y;
    if (x != -1) {
      a[x].push_back(i);
    } else if (x == -1)
      head = i;
  }
  dfs(head, 0);
  if (!meh.size()) {
    cout << -1 << endl;
  } else {
    sort(meh.begin(), meh.end());
    for (int i = 0; i < meh.size(); i++) {
      cout << meh[i] << " ";
    }
  }
}
