#include <bits/stdc++.h>
using namespace std;
vector<int> arr[100001];
vector<int> res(100001);
vector<int> vis(100001, 0);
set<int> s;
int cnt;
void dfs(int i) {
  vis[i] = 1;
  bool ans = 0;
  if (res[i] == 1) ans = 1;
  for (int j = 0; j < arr[i].size(); j++) {
    int a = arr[i][j];
    ans = (ans & res[a]);
    if (!vis[a]) dfs(a);
  }
  if (ans == 1) s.insert(i);
  return;
}
int main() {
  int n, a, b, src, i;
  cin >> n;
  cnt = 0;
  for (i = 1; i <= n; i++) {
    cin >> a >> b;
    if (a != -1) {
      arr[a].push_back(i);
    } else {
      src = i;
    }
    res[i] = b;
  }
  dfs(src);
  if (s.size() == 0)
    cout << "-1";
  else {
    for (auto it = s.begin(); it != s.end(); it++) {
      cout << *it << " ";
    }
  }
}
