#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 100005;
vector<long long> g[N];
long long a[N];
long long n;
set<long long> s;
bool vis[N];
void dfs(long long node) {
  if (a[node] == 1) {
    bool f = true;
    for (auto x : g[node]) {
      if (a[x] == 0) {
        f = false;
        break;
      }
    }
    if (f) s.insert(node);
  }
  for (auto x : g[node]) {
    dfs(x);
  }
}
int main() {
  cin >> n;
  long long par;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    if (x == -1) {
      par = i;
    } else {
      g[x].push_back(i);
    }
    a[i] = y;
  }
  dfs(par);
  if (s.size() > 0) {
    for (auto x : s) {
      cout << x << " ";
    }
    cout << endl;
    return 0;
  }
  cout << -1 << endl;
}
