#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long mo = 1e9 + 7;
long long sx, sy, ex, ey, dx[6] = {0, 1, 0, -1, 0, 0},
                          dy[6] = {1, 0, -1, 0, 0, 0}, m, n, k,
                          dz[6]{0, 0, 0, 0, -1, 1};
long long p, sg, no, v, re, ans, w, moo;
int par[500005];
long long b[400005];
long long a[400006], c[400006], dp[400005];
struct mat {
  long long a[40][40];
};
mat init, unit;
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
set<long long> se;
long long qu(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) {
      ans = ans % m * a % m;
    }
    b >>= 1;
    a = a % m * a % m;
  }
  return ans;
}
int su(int n) {
  if (n == 1 || n == 0) return 0;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
int fi(int a) {
  if (a == par[a])
    return a;
  else
    return par[a] = fi(par[a]);
}
vector<long long> ve, ve1;
string s1;
map<long long, long long> mp, mp1;
long long vis[500005];
int nu = 1, id = 1;
priority_queue<long long> que;
pair<long long, long long> a1[400000];
long long vis1[405][405], vis2[406][6];
int maze[505][505];
vector<long long> g[400000];
string s;
int cmp(pair<long long, long long> a, pair<long long, long long> b) {
  return (a.first - a.second) > (b.first - b.second);
}
long long ge(string s) {
  long long ans = 1;
  for (auto it : s) {
    ans *= it - '0';
  }
  return ans;
}
int main() {
  int t, p2, p3;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string ss, sss;
  long long l, r, n1;
  while (cin >> n) {
    for (int i = 1; i <= n; i++) par[i] = -1;
    for (int i = 1; i <= n; i++) {
      cin >> p >> a[i];
      if (p != -1) g[p].push_back(i);
      par[p] = i;
    }
    for (int i = 1; i <= n; i++) {
      if (a[i]) se.insert(i);
    }
    int fg = 0;
    while (se.size()) {
      sg = 1;
      no = *se.begin();
      se.erase(se.begin());
      for (int i = 0; i < g[no].size(); i++) {
        if (!a[g[no][i]]) {
          sg = 0;
          break;
        }
      }
      if (sg) {
        fg = 1;
        cout << no << " ";
        for (int i = 0; i < g[no].size(); i++) {
          par[g[no][i]] = par[no];
        }
      }
    }
    if (!fg) cout << -1;
    cout << endl;
    for (int i = 1; i <= n; i++) g[i].clear();
  }
}
