#include <bits/stdc++.h>
using namespace std;
vector<long long> v[200003];
vector<long long> v1;
long long to[200003];
long long pos[200003];
void dfs(long long p) {
  v1.push_back(p);
  pos[p] = v1.size() - 1;
  for (long long i = 0; i < v[p].size(); i++) {
    dfs(v[p][i]);
    to[p] += to[v[p][i]];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, q, x, k;
  cin >> n >> q;
  long long a[n];
  for (int i = int(0); i <= int(n); i++) {
    to[i] = 1;
  }
  for (int i = int(2); i <= int(n); i++) {
    cin >> a[i];
    v[a[i]].push_back(i);
  }
  dfs(1);
  while (q--) {
    cin >> x >> k;
    if (k > to[x]) {
      cout << -1 << endl;
    } else {
      cout << v1[pos[x] + k - 1] << endl;
    }
  }
}
