#include <bits/stdc++.h>
using namespace std;
const long long int MAX = -1000000000000000000;
const long long int MIN = 1000000000000000000;
const long long int inf = 1000000000;
const long long int KOK = 100000;
const long long int LOG = 30;
const long long int li = 3000005;
const long long int mod = 1000000007;
long long int n, m, cev, b, a[li], k, x, y;
string s;
vector<pair<int, int> > v[li];
map<long long int, long long int> mpp;
vector<long long int> vv;
void dfs(long long int node, long long int ata, long long int deger) {
  for (long long int i = 0; i < (long long int)v[node].size(); i++) {
    long long int go = v[node][i].first;
    if (go != ata)
      dfs(go, node, (v[node][i].second == 1 ? 1 : v[node][i].second));
    cout << deger << " " << node << " " << go << endl;
    cout << "**\n";
    if (v[ata][i].second == 0 && deger == 0) vv.push_back(node);
  }
}
int main() {
  long long int roott;
  scanf("%lld", &n);
  for (long long int i = 1; i <= n; i++) {
    scanf("%lld %lld", &x, &y);
    if (x) {
      if (y == 0) {
        mpp[x] = 1;
        mpp[i] = 1;
      }
    } else
      roott = i;
  }
  for (long long int i = 1; i <= n; i++) {
    if (mpp[i] == 0) {
      vv.push_back(i);
    }
  }
  if (vv.size() == 0) {
    printf("-1\n");
    return 0;
  }
  sort(vv.begin(), vv.end());
  for (long long int i = 0; i < (long long int)vv.size(); i++) {
    printf("%lld ", vv[i]);
  }
  return 0;
}
