#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > dt;
vector<int> dau;
int kq[200005];
int f[200005];
int dem = 0;
void init() {
  freopen(
      "e_bai3"
      ".inp",
      "r", stdin);
  freopen(
      "e_bai3"
      ".out",
      "w", stdout);
}
void Nhap() {
  int tmp;
  scanf("%d %d", &n, &m);
  dt.resize(n + 2, dau);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &tmp);
    dt[tmp].push_back(i);
  }
  dau.resize(n + 2, 0);
}
void DFS(int u) {
  int v;
  dau[u] = ++dem;
  kq[dem] = u;
  f[u] = 1;
  for (int i = 0; i < dt[u].size(); i++) {
    v = dt[u][i];
    if (dau[v] == 0) {
      DFS(v);
      f[u] += f[v];
    }
  }
}
void XuLi() {
  DFS(1);
  int u, k;
  while (m--) {
    scanf("%d %d", &u, &k);
    if (k > f[u])
      printf("-1\n");
    else
      printf("%d\n", kq[dau[u] + k - 1]);
  }
}
int main() {
  Nhap();
  XuLi();
}
