#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int par[n + 1];
  int res[n + 1];
  for (int i = 1; i <= n; i++) cin >> par[i] >> res[i];
  int child[n + 1];
  for (int i = 1; i <= n; i++) child[i] = 1;
  for (int i = 1; i <= n; i++)
    if (par[i] != -1) child[par[i]] = 0;
  int safe[n + 1];
  memset(safe, 0, sizeof(safe));
  for (int i = 1; i <= n; i++)
    if (par[i] != -1 && res[i] == 0) {
      safe[i] = 1;
      safe[par[i]] = 1;
    }
  set<int> ans;
  for (int i = 1; i <= n; i++)
    if (par[i] != -1)
      if (safe[i] == 0) ans.insert(i);
  for (auto u : ans) cout << u << " ";
  if (ans.size() == 0) cout << -1;
  return 0;
}
