#include <bits/stdc++.h>
using namespace std;
int root;
void addEdge(vector<int> adj[], int u, int v) {
  if (u == -1) {
    root = v;
    return;
  }
  adj[u].push_back(v);
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<int> res;
  int n, ctr, c;
  cin >> n;
  vector<int> adj[n + 1];
  vector<bool> vis(n + 1, false);
  for (int i = 0; i < n; i++) {
    cin >> ctr >> c;
    addEdge(adj, ctr, i + 1);
    if (c) vis[i + 1] = true;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) continue;
    auto it = adj[i].begin();
    for (; it != adj[i].end(); it++) {
      if (!vis[*it]) break;
    }
    if (it == adj[i].end()) res.push_back(i);
  }
  if (res.size() == 0)
    cout << -1;
  else
    for (int x : res) cout << x << " ";
}
