#include <bits/stdc++.h>
using namespace std;
int a[202020];
vector<int> tree[202020];
int b[202020];
int num[202020];
int ans = 0;
int v[202020], s[202020];
int dfs(int t) {
  ans++;
  b[ans] = t;
  v[t] = ans;
  s[ans] = t;
  num[t] = 1;
  int l = tree[t].size();
  for (int i = 0; i < l; i++) {
    num[t] += dfs(tree[t][i]);
  }
  return num[t];
}
int main() {
  int n, q;
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    tree[a[i]].push_back(i);
  }
  dfs(1);
  while (q--) {
    int u, k;
    cin >> u >> k;
    if (k > num[u])
      cout << "-1" << endl;
    else
      cout << s[v[u] + k - 1] << endl;
  }
}
