#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300000;
vector<int> g[MAX_N];
int sz[MAX_N];
int x[MAX_N];
int p[MAX_N];
int N;
int dfs(int v) {
  sz[v] = 1;
  p[v] = N;
  x[N++] = v;
  for (int i = 0; i < g[v].size(); i++) {
    sz[v] += dfs(g[v][i]);
  }
  return sz[v];
}
int main() {
  int n, q, a, b;
  cin >> n >> q;
  for (int i = 1; i < n; i++) {
    cin >> a;
    g[a - 1].push_back(i);
  }
  for (int i = 0; i < n; i++) sort(g[i].begin(), g[i].end());
  N = 0;
  dfs(0);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    a--;
    if (sz[a] < b)
      cout << -1 << endl;
    else
      cout << x[p[a] + b - 1] + 1 << endl;
  }
  return 0;
}
