#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long INF = 1e9;
const long long MOD = 1e9 + 7;
set<int> g[N];
int main() {
  int n;
  cin >> n;
  int p[N];
  int c[N];
  for (int i = 0; i < n; ++i) {
    cin >> p[i] >> c[i];
    if (p[i] != -1) {
      g[p[i] - 1].insert(i);
    }
  }
  vector<int> ans;
  for (int i = 0; i < n; ++i) {
    if (c[i]) {
      bool ok = 1;
      for (auto& j : g[i]) {
        if (j != -1 && !c[j]) ok = 0;
      }
      if (ok) {
        ans.push_back(i);
      }
    }
  }
  if (ans.empty()) {
    cout << -1;
  } else {
    for (int i = 0; i < ans.size(); ++i) cout << ans[i] + 1 << ' ';
  }
}
