#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
vector<int> e[N], v;
bool respect[N], res[N];
bool dfs(int i) {
  int tmp = 0;
  for (auto j : e[i]) tmp += dfs(j);
  res[i] = (tmp == (int)e[i].size() && respect[i]);
  return respect[i];
}
int main() {
  int n, r;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    int u;
    cin >> u >> respect[i];
    if (u + 1)
      e[u].push_back(i);
    else
      r = i;
  }
  dfs(r);
  int cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (res[i]) {
      cout << i << ' ';
      ++cnt;
    }
  }
  if (!cnt) cout << -1;
}
