#include <bits/stdc++.h>
using namespace std;
const long long N = 300100, mod = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 998244353,
                sq = 450, base = 727, lg = 25, inf = 1e18 + 10;
long long n, m, x, y, w, z, t, k, q, ans, c[N], p[N], rt;
set<int> f;
vector<int> v[N];
bool che1(long long x) {
  if (c[x] == 0) return false;
  for (int i = 0; i < v[x].size(); i++) {
    y = v[x][i];
    if (c[v[x][i]] == 0) return false;
  }
  return true;
}
void d(long long x) {
  if (che1(x)) f.insert(x);
  for (int i = 0; i < v[x].size(); i++) d(v[x][i]);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i + 1] >> c[i + 1];
    if (p[i + 1] == -1) p[i + 1] = 0, rt = i + 1;
    v[p[i + 1]].push_back(i + 1);
  }
  string first = "";
  for (int i = 0; i < n; i++) first += 'a';
  d(rt);
  if (f.empty()) return cout << -1, 0;
  while (!f.empty()) {
    x = *f.begin();
    f.erase(x);
    cout << x << ' ';
  }
}
