#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
vector<long long> g[N];
bool visited[N], resp[N];
bool flag = 0;
long long cnt[N];
set<long long> st;
void dfs(long long r) {
  for (auto it : g[r]) {
    cnt[r] += resp[it];
    dfs(it);
  }
  if (g[r].size() == cnt[r] && resp[r] == 1) {
    st.insert(r);
  }
}
int32_t main() {
  long long n;
  cin >> n;
  long long p, c, r = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> p >> resp[i];
    if (p == -1) {
      r = i;
      continue;
    }
    g[p].push_back(i);
  }
  dfs(r);
  if (st.empty()) {
    cout << -1;
  } else {
    for (auto it : st) {
      cout << it << " ";
    }
  }
  return 0;
}
