#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 69;
vector<int> adj[N];
vector<int> ve;
int n, root;
int p[N], c[N];
void dfs(int node, int par) {
  bool cek = (c[node] == 1);
  for (auto i : adj[node]) {
    if (i == par) continue;
    dfs(i, node);
    cek &= (c[i] == 1);
  }
  if (cek) ve.push_back(node);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (p[i] == -1) {
      root = i;
    } else {
      adj[p[i]].push_back(i);
      adj[i].push_back(p[i]);
    }
  }
  dfs(root, p[root]);
  sort(ve.begin(), ve.end());
  if (ve.empty())
    cout << -1 << "\n";
  else {
    for (auto i : ve) {
      cout << i << " ";
    }
    cout << "\n";
  }
  return 0;
}
