#include <bits/stdc++.h>
using namespace std;
int tt = 1;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool z = true;
  string r = "{";
  for (const auto& x : v) {
    if (!z) {
      r += ", ";
    }
    z = false;
    r += to_string(x);
  }
  r += "}";
  return r;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
void solve() {
  long long n, i, j, k, m;
  cin >> n;
  vector<long long> v[n + 1], c, a(n + 1, 0), b(n + 1), p(n + 1);
  for (i = 1; i <= n; i++) {
    cin >> j >> k;
    p[i] = j;
    b[i] = k;
    if (k == 0) {
      if (p[i] != -1) a[p[i]] = 1;
      a[i] = 1;
    }
  }
  for (i = 1; i <= n; i++) {
    if (a[i] == 0) c.push_back(i);
  }
  sort(c.begin(), c.end());
  if (c.size() == 0)
    cout << "-1";
  else {
    for (auto e : c) {
      cout << e << " ";
    }
  }
}
int main() {
  cout << setprecision(15);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while (tt--) {
    solve();
  }
}
