#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, c[N], root, a;
vector<int> v[N], ans;
void dfs(int x) {
  for (auto y : v[x]) {
    c[x] *= c[y];
    dfs(y);
  }
  if (x != root)
    if (c[x]) ans.push_back(x);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a, &c[i]);
    if (a != -1)
      v[a].push_back(i);
    else
      root = i;
  }
  dfs(root);
  sort(ans.begin(), ans.end());
  for (auto x : ans) printf("%d ", x);
  if (ans.empty()) printf("-1");
  return 0;
}
