#include <bits/stdc++.h>
int size[200500], qq[200500];
struct ed {
  int to, next;
} edge[200500];
int cnt = 0, head[200500], dfn = 0, wht[200500], df[200500];
void DFS(int x) {
  dfn++;
  wht[dfn] = x;
  df[x] = dfn;
  int hjy = 1;
  if (head[x] == 0) {
    size[x] = 1;
    return;
  }
  for (int i = head[x]; i; i = edge[i].next) {
    DFS(edge[i].to);
    hjy += size[edge[i].to];
  }
  size[x] = hjy;
}
void add(int x, int y) {
  ++cnt;
  edge[cnt].to = y;
  edge[cnt].next = head[x];
  head[x] = cnt;
}
int main() {
  int n, q;
  scanf("%d%d", &n, &q);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &qq[i]);
  }
  for (int i = n; i >= 2; i--) {
    add(qq[i], i);
  }
  DFS(1);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (size[x] < y)
      printf("-1\n");
    else
      printf("%d\n", wht[df[x] + y - 1]);
  }
  return 1 - 1;
}
