#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 100123;
int n;
int c[N_MAX];
int parent[N_MAX];
bool visited[N_MAX];
bool respected[N_MAX];
int root;
vector<int> result;
vector<int> A[N_MAX];
void dfs(int v) {
  visited[v] = true;
  for (unsigned int i = 0; i < A[v].size(); i++) {
    int u = A[v][i];
    if (!visited[u]) {
      dfs(u);
    }
  }
  if (c[v] == 0) {
    respected[parent[v]] = true;
  } else {
    if (!respected[v]) {
      result.push_back(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> parent[i];
    cin >> c[i];
    if (parent[i] == -1) {
      root = i;
    } else {
      A[i].push_back(parent[i]);
      A[parent[i]].push_back(i);
    }
  }
  dfs(root);
  if (result.empty()) {
    cout << -1 << '\n';
  } else {
    sort(result.begin(), result.end());
    for (unsigned int i = 0; i < result.size(); i++) {
      cout << result[i] << " ";
    }
    cout << '\n';
  }
  return 0;
}
