#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
int father[100005], flag[100005], n, sum, root;
vector<int> son[100005];
queue<int> q;
int ans, q1[100005];
void bfs() {
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = 0; i < son[x].size(); i++) {
      q.push(son[x][i]);
    }
    if (father[x] && flag[x]) {
      int flag1 = 0;
      for (int i = 0; i < son[x].size(); i++) {
        if (!flag[son[x][i]]) {
          flag1 = 1;
          break;
        }
      }
      if (!flag1) {
        q1[ans++] = x;
        sum++;
        for (int i = 0; i < son[x].size(); i++) {
          father[son[x][i]] = father[x];
        }
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int f;
    cin >> f >> flag[i];
    if (f == -1)
      root = i;
    else {
      father[i] = f;
      son[f].push_back(i);
    }
  }
  q.push(root);
  bfs();
  if (sum == 0)
    cout << -1 << endl;
  else {
    sort(q1, q1 + ans);
    for (int i = 0; i < ans; i++) cout << q1[i] << " ";
  }
  return 0;
}
