#include <bits/stdc++.h>
using namespace std;
const int maxn = 100020;
int vis1[maxn], vis2[maxn];
int n, x, flag = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x >> vis1[i];
    if (vis1[i] == 0) {
      vis2[x] = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (vis2[i] == 0 && vis1[i] == 1) {
      flag = 1;
      cout << i << " ";
    }
  }
  if (!flag) cout << "-1" << endl;
  return 0;
}
