#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5, mod = 1e9 + 7, MAX = (1 << 18), oo = 1e18;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int n, C[N];
vector<vector<int>> g;
vector<int> vv;
void dfs(int u, int par) {
  bool r = 1;
  for (auto v : g[u]) {
    if (v != par) {
      if (C[v] == 0) r = 0;
      dfs(v, u);
    }
  }
  if (C[u] && r) vv.push_back(u);
}
int main() {
  ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  cin >> n;
  g.resize(n + 5);
  int root = -1;
  for (int i = 1; i <= n; i++) {
    int v, c;
    cin >> v >> C[i];
    if (v == -1) {
      root = i;
      continue;
    }
    g[v].push_back(i);
  }
  dfs(root, -1);
  sort(vv.begin(), vv.end());
  if (vv.size() == 0) {
    cout << -1;
    return 0;
  }
  for (auto i : vv) cout << i << ' ';
  return 0;
}
