#include <bits/stdc++.h>
using namespace std;
mt19937 _g(time(nullptr));
long long randint(long long a, long long b) {
  long long w = (_g() << 31ll) ^ _g();
  return a + w % (b - a + 1);
}
void boot_up() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(4);
}
const long long INF = 1e18, maxn = 2e5;
long long p[maxn], c[maxn], cnt[maxn];
vector<long long> g[maxn];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> p[i] >> c[i];
    if (p[i] == -1) p[i] = 0;
    g[i].push_back(p[i]);
    g[p[i]].push_back(i);
    if (c[i] == 1) cnt[p[i]]++;
  }
  vector<long long> ans;
  for (long long i = 1; i <= n; ++i)
    if ((g[i].size() - 1) == cnt[i] && c[i] == 1) {
      ans.push_back(i);
    }
  if (ans.size() == 0) {
    cout << -1 << "\n";
    return;
  }
  sort(ans.begin(), ans.end());
  for (auto item : ans) cout << item << " ";
  cout << "\n";
}
signed main() {
  boot_up();
  solve();
  return 0;
}
