#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int par[n + 1];
  int res[n + 1];
  int root;
  for (int i = 1; i <= n; i++) {
    cin >> par[i] >> res[i];
    if (par[i] == -1) root = i;
  }
  int ans[n + 1];
  for (int i = 0; i <= n; i++) ans[i] = 0;
  ans[root] = 1;
  for (int i = 1; i <= n; i++) {
    if (res[i] == 0) {
      ans[par[i]] = 1;
      ans[i] = 1;
    }
  }
  int flag = 0;
  for (int i = 1; i <= n; i++) {
    if (ans[i] == 0) {
      cout << i << " ";
      flag = 1;
    }
  }
  if (flag == 0) cout << "-1";
  cout << "\n";
  return 0;
}
