#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> parent(n + 1);
  vector<int> C(n + 1);
  vector<int> white;
  vector<bool> visited(n + 1);
  for (int i = int(1); i <= int(n); i++) {
    int p, c;
    cin >> p >> c;
    parent[i] = p;
    C[i] = c;
    if (c == 0) {
      white.push_back(i);
      visited[i] = true;
    }
  }
  vector<int> BFS = white;
  if (true) {
    vector<int> new_BFS;
    for (auto v : BFS) {
      if (parent[v] == -1) continue;
      if (visited[parent[v]]) continue;
      visited[parent[v]] = true;
      new_BFS.push_back(parent[v]);
      white.push_back(parent[v]);
    }
    BFS = new_BFS;
  }
  int visits = 0;
  for (int i = int(1); i <= int(n); i++) {
    if (!visited[i]) cout << i << " ";
    if (visited[i]) visits++;
  }
  if (visits == n) cout << -1 << " ";
  cout << endl;
  return 0;
}
