#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
bitset<200010> vis;
vector<int> path;
int ndec[200010] = {0}, ix[200010];
void dfs(int cn) {
  path.push_back(cn);
  vis[cn] = 1;
  for (int i = 0; i < adj[cn].size(); i++) {
    if (!vis[adj[cn][i]]) {
      dfs(adj[cn][i]);
      ndec[cn] += ndec[adj[cn][i]] + 1;
    }
  }
}
int main() {
  int n, q, x, k;
  cin >> n >> q;
  vis.reset();
  adj = vector<vector<int> >(n, vector<int>());
  for (int i = 1; i < n; i++) {
    cin >> x;
    x--;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  for (int i = 0; i < n; i++) sort(adj[i].begin(), adj[i].end());
  dfs(0);
  for (int i = 0; i < path.size(); i++) ix[path[i]] = i;
  while (q--) {
    cin >> x >> k;
    x--;
    if (ndec[x] + 1 >= k)
      cout << path[ix[x] + k - 1] + 1;
    else {
      cout << -1;
    }
    cout << endl;
  }
  return 0;
}
