#include <bits/stdc++.h>
using namespace std;
double pi = M_PI;
vector<int> v[100005];
vector<int> check(100005, 0);
vector<int> ans;
int vis[100005] = {0};
void dfs(int x) {
  int f = 0;
  vis[x] = 1;
  if (check[x] == 1) {
    for (auto c : v[x]) {
      if (vis[c] == 0 && check[c] == 0) f = 1;
    }
    if (f == 0) ans.push_back(x);
  }
  for (auto c : v[x]) {
    if (vis[c] == 0) dfs(c);
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int t = 1;
  while (t--) {
    int n, root, i;
    cin >> n;
    for (i = 1; i <= n; i++) {
      int p, c;
      cin >> p >> c;
      if (p == -1) {
        root = i;
      } else {
        v[i].push_back(p);
        v[p].push_back(i);
      }
      check[i] = c;
    }
    for (i = 1; i <= n; i++) {
      sort(v[i].begin(), v[i].end());
    }
    dfs(root);
    sort(ans.begin(), ans.end());
    if (((int)ans.size()) == 0)
      cout << "-1";
    else {
      for (auto a : ans) cout << a << " ";
    }
  }
}
