#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = LONG_LONG_MAX;
const ll N = 1e5 + 5;
ll p[N];
ll c[N];
vector<ll> adj[N];
vector<ll> v;
void dfs(ll node, ll par) {
  ll valid = (p[node] != (-1) and c[node]);
  for (ll i : adj[node]) {
    if (c[i] == 0) {
      valid = 0;
    }
    dfs(i, node);
  }
  if (valid) {
    v.push_back(node);
  }
}
signed main() {
  ll n;
  cin >> n;
  ll root;
  for (ll i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == (-1)) {
      root = i;
    } else {
      adj[p[i]].push_back(i);
    }
  }
  for (ll i = 1; i <= n; i++) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(root, (-1));
  sort(v.begin(), v.end());
  if (v.size() == 0) {
    cout << "-1\n";
  } else {
    for (ll i : v) {
      cout << i << " ";
    }
    cout << "\n";
  }
  return 0;
}
