#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int can[N], c[N];
vector<int> adj[N];
void dfs(int u) {
  int t = c[u];
  for (auto v : adj[u]) {
    t &= c[v];
    dfs(v);
  }
  can[u] = t;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, par, ok = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    if (p == -1)
      par = i;
    else
      adj[p].push_back(i);
  }
  dfs(par);
  for (int i = 1; i <= n; i++) {
    if (can[i]) {
      cout << i << " ";
      ok = 1;
    }
  }
  if (!ok) cout << -1 << endl;
  return 0;
}
