#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 5;
const long double pi = 3.14159265;
long long gcd(long long a_, long long b_) {
  if (b_ > a_) swap(b_, a_);
  return (b_ == 0 ? a_ : gcd(b_, a_ % b_));
}
long long p[N], c[N], ty[N], n, con = 0;
vector<long long> v[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> p[i] >> c[i];
    if (c[i] == 0) {
      ty[i] = 1;
      ty[p[i]] = 1;
    }
  }
  for (long long i = 1; i <= n; i++) {
    if (!ty[i]) {
      cout << i << " ";
      con = 1;
    }
  }
  if (!con) cout << -1;
  return 0;
}
