#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
vector<int> edges[maxn], ans;
int p[maxn], c[maxn], vis[maxn];
void dfs(int u) {
  if (!vis[u]) {
    vis[u] = 1;
    if (c[u] == 1) {
      int cnt = 0, sz = 0;
      for (auto v : edges[u]) {
        if (p[u] != v) {
          ++sz;
          if (c[v] == 1) ++cnt;
        }
      }
      if (cnt == sz) ans.push_back(u);
    }
    for (auto v : edges[u]) {
      if (!vis[v]) dfs(v);
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int root;
  for (int u = 1; u <= n; ++u) {
    scanf("%d %d", &p[u], &c[u]);
    if (p[u] == -1 && c[u] == 0)
      root = u;
    else {
      edges[u].push_back(p[u]);
      edges[p[u]].push_back(u);
    }
  }
  dfs(root);
  sort(ans.begin(), ans.end());
  if (ans.empty())
    puts("-1");
  else {
    for (auto u : ans) printf("%d ", u);
  }
}
