#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const int maxn = 2e5 + 5;
long long gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
long long pow_mod(long long a, long long b, long long mod) {
  long long res = 1;
  while (b != 0) {
    if (b & 1) res = res * a % mod;
    b >>= 1;
    a = a * a % mod;
  }
  return res;
}
int a[maxn];
vector<int> g[maxn], ans;
void dfs(int s) {
  if (a[s] == 0) {
    for (auto k : g[s]) dfs(k);
  } else {
    int flag = 1;
    for (auto k : g[s]) {
      if (a[k] == 0) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) ans.push_back(s);
    for (auto k : g[s]) dfs(k);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(0);
  ;
  int n, p, c, root;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p >> c;
    if (p == -1)
      root = i, a[i] = 0;
    else {
      g[p].push_back(i);
      a[i] = c;
    }
  }
  dfs(root);
  if (ans.size() == 0) return cout << -1 << endl, 0;
  sort(ans.begin(), ans.end());
  for (auto it = ans.begin(); it != ans.end(); it++) {
    if (it != ans.end() - 1)
      cout << *it << " ";
    else
      cout << *it << endl;
  }
  return 0;
}
