#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> adj[N];
int n, st[N], sz[N], flat[N], tim = 1;
int dfs(int u) {
  int s = 1;
  st[u] = tim;
  flat[tim] = u;
  for (int v : adj[u]) {
    tim++;
    s += dfs(v);
  }
  return sz[u] = s;
}
int main(int argc, char const *argv[]) {
  int q;
  cin >> n >> q;
  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    adj[p].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    sort(adj[i].begin(), adj[i].end());
  }
  dfs(1);
  while (q--) {
    int u, k;
    cin >> u >> k;
    if (k > sz[u])
      cout << -1 << '\n';
    else
      cout << flat[st[u] + k - 1] << '\n';
  }
  return 0;
}
