#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 6;
vector<int> v[N];
set<int> s;
vector<int> vis(N);
int b[N], k;
void dfs(int a) {
  int c = 0;
  if (!vis[a]) {
    vis[a] = true;
    for (auto i : v[a]) {
      if (!vis[i]) dfs(i);
      if (b[i] == 1) c++;
    }
    if (c == v[a].size() && b[a] == 1) s.insert(a);
  }
}
int main() {
  int t;
  cin >> t;
  int a[t + 1];
  for (int i = 1; i <= t; ++i) {
    cin >> a[i] >> b[i];
    if (a[i] == -1) {
      k = i;
      continue;
    }
    v[a[i]].push_back(i);
  }
  dfs(k);
  if (s.size() == 0)
    cout << -1;
  else
    for (auto i : s) cout << i << " ";
}
