#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> vec[N];
int st[N], dfn[N], ct;
int siz[N];
void dfs(int);
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ct = 0;
  int p;
  for (int i = 2; i <= n; i++) {
    scanf("%d", &p);
    vec[p].push_back(i);
  }
  dfs(1);
  int u, k;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &u, &k);
    if (k > siz[u])
      puts("-1");
    else {
      printf("%d\n", dfn[st[u] + k - 1]);
    }
  }
  return 0;
}
void dfs(int u) {
  st[u] = ++ct, dfn[ct] = u;
  siz[u] = 1;
  for (int i = 0; i < (int)vec[u].size(); i++) {
    int v = vec[u][i];
    dfs(v);
    siz[u] += siz[v];
  }
}
