#include <bits/stdc++.h>
using namespace std;
vector<long long> powers2(32, 0);
void initialize() {
  for (long long i = 1; i < powers2.size(); i++)
    powers2[i] = powers2[i - 1] * 2;
}
inline bool is_palindrome(const string &s) {
  return std::equal(s.begin(), s.end(), s.rbegin());
}
map<long long, vector<long long>> mp;
vector<long long> c, nx;
void bfs(long long src, long long size) {
  queue<long long> q;
  q.push(src);
  while (!q.empty()) {
    long long x = q.front();
    q.pop();
    long long flag = 1;
    for (auto val : mp[x]) {
      if (c[val] != 1) flag = 0;
      q.push(val);
    }
    if (flag == 1 && c[x] == 1) nx.push_back(x);
  }
}
int32_t main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long a[n], src;
  c.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i] >> c[i];
    if (a[i] != -1)
      mp[a[i] - 1].push_back(i);
    else
      src = i;
  }
  bfs(src, n);
  if (nx.size() == 0) cout << -1;
  sort(begin(nx), end(nx));
  for (auto val : nx) cout << val + 1 << " ";
  auto end = chrono::high_resolution_clock::now();
  double time_taken =
      chrono::duration_cast<chrono::nanoseconds>(end - start).count();
  time_taken *= 1e-9;
  return 0;
}
