#include <bits/stdc++.h>
using namespace std;
auto clk = clock();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(8);
  long long int n;
  cin >> n;
  long long int p, c;
  vector<long long int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> p >> c;
    if (p != -1 && c == 0) {
      a[p - 1] = 1;
    }
    if (c == 0) {
      a[i] = 1;
    }
  }
  long long int out = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      cout << i + 1 << " ";
      out = 1;
    }
  }
  if (out == 0) {
    cout << -1 << " ";
  }
  cout << "\n";
  return 0;
}
