#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e6 + 10;
bool vis[N];
int a[N], c[N], cnt, sum;
vector<int> v[N], u;
set<pair<int, int>> ss;
void dfs(int s) {
  int k = 0;
  if (v[s].size() == 0) {
    u.push_back(s);
    return;
  }
  for (int i = 0; i < v[s].size(); i++) {
    if (c[v[s][i]] == 0) {
      k = 1;
      break;
    }
  }
  if (k == 0) u.push_back(s);
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x, y, n, m, k, i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x >> c[i];
    if (x == -1) {
      k = i;
      continue;
    }
    v[x].push_back(i);
  }
  for (i = 1; i <= n; i++) {
    if (i != k && c[i] == 1) {
      dfs(i);
    }
  }
  if (u.size() == 0) return cout << -1, 0;
  for (i = 0; i < u.size(); i++) cout << u[i] << " ";
}
