#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, rt;
int fa[MAXN], c[MAXN];
vector<int> G[MAXN];
vector<int> ans;
void bfs(int root) {
  queue<int> q;
  q.push(root);
  while (q.size()) {
    int x = q.front();
    q.pop();
    int flag = 1;
    for (auto &y : G[x]) {
      if (c[y] == 0) flag = 0;
      q.push(y);
    }
    if (c[x] == 1 && flag) ans.push_back(x);
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    fa[i] = read();
    if (fa[i] == -1)
      rt = i;
    else
      G[fa[i]].push_back(i);
    c[i] = read();
  }
  bfs(rt);
  sort(ans.begin(), ans.end());
  if (((int)ans.size()) == 0) cout << -1;
  for (int i = 0; i < ((int)ans.size()); i++) cout << ans[i] << ' ';
  return 0;
}
