#include <bits/stdc++.h>
using namespace std;
const int G_V = 1, G_U = -1;
int V;
vector<std::vector<int> > adjlist;
std::vector<int> sequence;
std::vector<int> numchildren;
std::vector<int> pos;
int dbfsi = 0;
int dbfs(int u) {
  pos[u] = dbfsi;
  sequence[dbfsi] = u;
  ++dbfsi;
  for (int v : adjlist[u]) {
    numchildren[u] += 1 + dbfs(v);
  }
  return numchildren[u];
}
void SOLVE() {
  int Q;
  cin >> V >> Q;
  adjlist.assign(V, std::vector<int>());
  for (int i = 1; i < V; ++i) {
    int p;
    cin >> p;
    --p;
    adjlist[p].push_back(i);
  }
  for (std::vector<int> v : adjlist) {
    sort(begin(v), end(v));
  }
  sequence.resize(V);
  numchildren.assign(V, 0);
  pos.resize(V);
  dbfsi = 0;
  dbfs(0);
  while (Q--) {
    int u, k;
    cin >> u >> k;
    --u;
    --k;
    if (pos[u] + k >= V || k > numchildren[u]) {
      cout << -1 << '\n';
      continue;
    }
    cout << sequence[pos[u] + k] + 1 << '\n';
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  SOLVE();
}
