#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[100005];
vector<long long int> vis(100005, 0);
vector<long long int> p(100005, 0);
long long int c[100005];
void dfs(long long int node) {
  if (vis[node]) return;
  vis[node] = 1;
  for (auto i : adj[node]) {
    p[node] += c[i];
    dfs(i);
  }
}
int main() {
  long long int n, u, i, root;
  vector<long long int> ans;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> u >> c[i];
    if (u != -1) adj[u].push_back(i);
    if (u == -1) root = i;
  }
  dfs(root);
  for (i = 1; i <= n; i++) {
    if (c[i] == 1) {
      if (p[i] == adj[i].size()) ans.push_back(i);
    }
  }
  if (ans.empty()) {
    cout << "-1";
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (i = 0; i < ans.size(); i++) cout << ans[i] << " ";
}
