#include <bits/stdc++.h>
using namespace std;
const long long N = 200002;
long long n, par[N], r, c[N], tmp = 0, a[N], x[N];
vector<int> g[N];
pair<int, int> p[N];
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) {
    return true;
  } else if (a.first < b.first) {
    return false;
  } else {
    if (a.second < b.second) {
      return true;
    } else {
      return false;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int y, pa;
    cin >> pa >> y;
    c[i] = y;
    if (pa == -1) {
      r = i;
    } else {
      par[i] = pa;
      g[pa].push_back(i);
      p[i].first = y;
      p[i].second = i;
      x[pa] += y;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (x[i] == g[i].size() && c[i] == 1) {
      tmp = 1;
      cout << i << " ";
    }
  }
  if (tmp == 0) cout << -1;
  return 0;
}
