#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
int n, a[N], b[N], f[N];
set<int> st;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    if (a[i] != -1) f[a[i]] += b[i] ^ 1;
  }
  for (int i = 1; i <= n; ++i) {
    if (!(f[i] || !b[i])) st.insert(i);
  }
  if (!int(st.size())) {
    cout << -1;
    return 0;
  }
  for (auto to : st) cout << to << " ";
  return 0;
}
