#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
vector<int> g[N];
int n, res[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int p, c;
    cin >> p >> res[i];
    if (p != -1) g[p - 1].push_back(i);
  }
  vector<int> order;
  for (int i = 0; i < n; ++i) {
    int c = 0;
    for (auto &v : g[i])
      if (res[v]) ++c;
    if (c == g[i].size() && res[i]) order.push_back(i);
  }
  if (!order.empty()) {
    sort(order.begin(), order.end());
    for (auto &v : order) cout << v + 1 << " ";
    cout << endl;
  } else
    cout << -1 << endl;
  return 0;
}
