#include <bits/stdc++.h>
using namespace std;
bool vis[100005], flag[100005];
int ans[100005];
vector<int> g[100005];
int n, cnt = 0;
void dfs(int x) {
  if (flag[x]) {
    int num = g[x].size(), i = 0, y, k = 0;
    for (i = 0; i < num; ++i) {
      y = g[x][i];
      if (flag[y]) k++;
      dfs(y);
    }
    if (k == num) ans[cnt++] = x;
  } else {
    int num = g[x].size(), y;
    for (int i = 0; i < num; ++i) {
      y = g[x][i];
      dfs(y);
    }
  }
}
int main() {
  int i, root, par;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &par, &flag[i]);
    if (par == -1)
      root = i;
    else {
      g[par].push_back(i);
    }
  }
  dfs(root);
  if (cnt == 0) {
    printf("-1");
  } else {
    sort(ans, ans + cnt);
    for (i = 0; i < cnt; ++i) printf("%d ", ans[i]);
  }
  return 0;
}
