#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010], ans;
bool vis[100010];
bool c[100010];
void find(int v) {
  vis[v] = true;
  bool del = true;
  for (int u : adj[v]) {
    del &= c[u];
    if (!vis[u]) find(u);
  }
  if (c[v] && del) ans.push_back(v);
}
int main() {
  int n;
  cin >> n;
  int root;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    if (p != -1)
      adj[p].push_back(i);
    else
      root = i;
  }
  find(root);
  sort(ans.begin(), ans.end());
  if (ans.empty()) cout << "-1";
  for (int v : ans) cout << v << " ";
  cout << endl;
  return 0;
}
