#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, long long int>> adj[100005];
long long int arr[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t, a, b, i, parent, j, c, d = 0;
  cin >> t;
  for (i = 1; i <= t; i++) {
    cin >> a >> b;
    if (a != -1) {
      adj[a].push_back(make_pair(i, b));
      arr[i] = b;
    } else
      parent = i;
  }
  for (i = 1; i <= t; i++) {
    if (arr[i] == 1) {
      c = 0;
      for (j = 0; j < adj[i].size(); j++) {
        if (adj[i][j].second == 1) c++;
      }
      if (c == adj[i].size()) {
        cout << i << " ";
        d++;
      }
    }
  }
  if (d == 0) cout << "-1";
}
