#include <bits/stdc++.h>
using namespace std;
int n, a, parent;
vector<int> v[100003], ans;
bool c[100003];
void dfs(int r, int p) {
  int flag = 1;
  if (c[r] == 0) flag = 0;
  for (auto u : v[r]) {
    if (!c[u]) flag = 0;
    dfs(u, r);
  }
  if (flag == 1) ans.push_back(r);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> c[i];
    if (a == -1) {
      parent = i;
      continue;
    }
    v[a].push_back(i);
  }
  dfs(parent, -1);
  if (ans.empty()) {
    cout << -1;
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (auto u : ans) cout << u << ' ';
}
