#include <bits/stdc++.h>
using namespace std;
long long gcd(unsigned long long x, unsigned long long y) {
  if (x == 0) return y;
  return gcd(y % x, x);
}
unsigned long long findGCD(vector<unsigned long long> &v) {
  unsigned long long result = v[0];
  for (long long i = 1; i < v.size(); i++) {
    result = gcd(v[i], result);
    if (result == 1) {
      return 1;
    }
  }
  return result;
}
long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }
bool sortbysec(long long a, long long b) { return (a > b); }
vector<long long> primeFactors(long long n) {
  vector<long long> ans;
  while (n % 2 == 0) {
    ans.push_back(2);
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      ans.push_back(i);
      n = n / i;
    }
  }
  if (n > 2) ans.push_back(n);
  return ans;
}
vector<long long> all_prime(long long n) {
  vector<long long> sieve(n + 1, 0);
  for (long long x = 2; x <= n; x++) {
    if (sieve[x]) continue;
    for (int u = 2 * x; u <= n; u += x) {
      if (sieve[u] == 0) {
        sieve[u] = x;
      }
    }
  }
  return sieve;
}
long long power(long long x, long long n) {
  if (n == 0) return 1;
  long long temp = power(x, n / 2);
  if (n % 2 == 0)
    return temp * temp;
  else
    return x * temp * temp;
}
unsigned long long powerper(unsigned long long x, long long y, long long p) {
  unsigned long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
unsigned long long modInverse(unsigned long long n, long long p) {
  return powerper(n, p - 2, p);
}
unsigned long long nCrModPFermat(unsigned long long n, long long r, long long p,
                                 unsigned long long fac[]) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void dfs(vector<vector<long long>> &v, vector<long long> &df, long long seen[],
         long long i, long long p[]) {
  if (p[i] == 1) {
    long long x = 0, y = 0;
    if (v[i].size() == 1 && seen[v[i][0]] != 0)
      df.push_back(i);
    else {
      for (long long j = 0; j < v[i].size(); j++) {
        if (seen[v[i][j]] == 0 && p[v[i][j]] == 1) x++;
      }
      if (x == v[i].size() - 1) df.push_back(i);
    }
  }
  for (long long j = 0; j < v[i].size(); j++) {
    if (seen[v[i][j]] == 0) {
      seen[v[i][j]] = seen[i];
      dfs(v, df, seen, v[i][j], p);
    }
  }
}
void bfs(vector<vector<long long>> &v, long long root, long long seen[]) {
  queue<long long> q;
  seen[root - 1] = 1;
  q.push(root - 1);
  while (!q.empty()) {
    for (long long i = 0; i < v[q.front()].size(); i++) {
      if (seen[v[q.front()][i]] != 1) {
        q.push(v[q.front()][i]);
        seen[v[q.front()][i]] = 1;
      }
    }
    q.pop();
  }
}
void djikstra(vector<pair<long long, long long>> v[], long long d[],
              long long par[], long long second, long long n) {
  for (long long i = 0; i < n; i++) {
    d[i] = 1000000001;
    par[i] = -1;
  }
  par[second] = second;
  d[second] = 0;
  bool cov[n];
  for (long long i = 0; i < n; i++) cov[i] = 0;
  long long u = -1;
  for (int j = 0; j < n; j++) {
    u = -1;
    for (long long i = 0; i < n; i++) {
      if (!cov[i] && (d[i] < d[u] || u == -1)) u = i;
    }
    cov[u] = 1;
    for (long long i = 0; i < v[u].size(); i++) {
      if (d[v[u][i].first] > d[u] + v[u][i].second) {
        d[v[u][i].first] = d[u] + v[u][i].second;
        par[v[u][i].first] = u;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, root = 0;
  cin >> n;
  vector<vector<long long>> v(n);
  vector<long long> v1;
  long long seen[n];
  for (long long i = 0; i < n; i++) seen[i] = 0;
  long long p[n];
  for (long long i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x == -1)
      root = i;
    else {
      v[i].push_back(x - 1);
      v[x - 1].push_back(i);
    }
    p[i] = y;
  }
  seen[root] = root + 1;
  dfs(v, v1, seen, root, p);
  if (v1.size() == 0)
    cout << "-1";
  else {
    if (v1.size() == 1 && v1[0] == root)
      cout << "-1";
    else {
      sort(v1.begin(), v1.end());
      for (long long j = 0; j < v1.size(); j++) {
        if (v1[j] != root) cout << v1[j] + 1 << " ";
      }
    }
  }
}
