#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5 + 7;
int n, c[NMAX], ok[NMAX];
vector<int> g[NMAX];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p;
    cin >> p >> c[i];
    if (p > 0) g[p].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    int vazi = 1;
    if (c[i] == 0) vazi = 0;
    for (int j : g[i])
      if (c[j] == 0) vazi = 0;
    if (vazi) ok[i] = 1;
    if (ok[i]) v.push_back(i);
  }
  sort(v.begin(), v.end());
  for (int i : v) cout << i << " ";
  if (v.empty()) cout << -1 << endl;
  return 0;
}
