#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
long long n, pre[100001], c[100001];
vector<long long> pot[100001];
bool g = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> pre[i] >> c[i];
    pot[pre[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (pre[i] == -1 || c[i] == 0) continue;
    bool f = 1;
    for (auto j : pot[i])
      if (c[j] == 0) f = 0;
    if (f) cout << i << " ", g = 1;
  }
  if (!g) cout << "-1 ";
  return 0;
}
