#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int>> adj;
vector<long long int> resp, del;
void DFS(long long int cur, long long int par) {
  long long int f = 0;
  if (resp[cur] == 1) {
    for (auto x : adj[cur]) {
      if (x == par) continue;
      if (resp[x] == 0) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      del.push_back(cur);
    }
  }
  for (auto x : adj[cur]) {
    if (x == par) continue;
    DFS(x, cur);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, i, a, root;
  cin >> n;
  resp.resize(n + 1);
  adj.resize(n + 1);
  for (i = 1; i <= n; i++) {
    cin >> a >> resp[i];
    if (a == -1)
      root = i;
    else {
      adj[a].push_back(i);
      adj[i].push_back(a);
    }
  }
  DFS(root, -1);
  if (del.size() == 0)
    cout << "-1";
  else {
    sort(del.begin(), del.end());
    for (auto x : del) {
      cout << x << " ";
    }
  }
}
