#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int nod, i, j, k, t;
  cin >> nod;
  int yellow[nod + 1], par[nod + 1];
  for (i = 1; i <= nod; i++) {
    cin >> k >> t;
    par[i] = k;
    yellow[i] = t;
    if (k != -1) {
      v[k].push_back(i);
    }
  }
  int flag2 = 0;
  for (i = 1; i <= nod; i++) {
    if (yellow[i] == 1) {
      int flag = 0;
      for (j = 0; j < v[i].size(); j++) {
        int curr = v[i][j];
        if (yellow[curr] == 0) {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        flag2 = 1;
        cout << i << " ";
      }
    }
  }
  if (flag2 == 0) {
    cout << -1;
  }
  return 0;
}
