#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int inf = 1 << 30;
const int mod = 1e9 + 7;
vector<int> num[2 * maxn];
queue<int> qwe;
map<int, int> mp;
map<int, int> vis;
int n, m, u, v, t;
int ind[2 * maxn];
int con = 0;
int k;
struct point {
  int x, flag;
} p, q;
queue<point> que;
void Dfs(int x) {
  ind[x] = 1;
  vis[k] = x;
  mp[x] = k++;
  for (int i = 0; i < num[x].size(); i++) {
    int s = num[x][i];
    Dfs(s);
    ind[x] += ind[s];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &u);
    num[u].push_back(i);
  }
  k = 1;
  Dfs(1);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    int pos = mp[u] + v - 1;
    if (v > ind[u])
      printf("-1\n");
    else
      printf("%d\n", vis[pos]);
  }
  return 0;
}
