#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
string s;
bool ok;
vector<pair<int, int> > g[N];
bool vis[N];
set<pair<int, int> > st;
void dfs(pair<int, int> v) {
  vis[v.first] = true;
  for (auto [u, val] : g[v.first]) {
    if (!vis[u]) dfs({u, val});
  }
  if (v.second == 1) {
    bool ok = true;
    for (auto [a, b] : g[v.first]) {
      if (b == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      st.insert(v);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  pair<int, int> par;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int u, v;
    cin >> u >> v;
    if (u == -1) {
      par = {i, v};
      continue;
    }
    g[u].push_back({i, v});
  }
  dfs(par);
  if (!((int)(st).size())) {
    return cout << -1, 0;
  }
  for (auto [x, y] : st) {
    cout << x << ' ';
  }
  cout << '\n';
}
