#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > gr;
vector<int> ans, sz;
void dfs(int v) {
  sz[v] = 1;
  ans.push_back(v);
  for (auto to : gr[v]) {
    dfs(to);
    sz[v] += sz[to];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  gr.resize(n);
  sz.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    gr[x - 1].push_back(i + 1);
  }
  dfs(0);
  vector<int> id(n);
  for (int i = 0; i < n; i++) {
    id[ans[i]] = i;
  }
  while (q--) {
    int u, k;
    cin >> u >> k;
    if (sz[u - 1] < k) {
      cout << -1 << endl;
      continue;
    }
    cout << ans[id[u - 1] + k - 1] + 1 << endl;
  }
  return 0;
}
