#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
void dfs(int v, vector<bool> &visited, vector<vector<int>> &path,
         vector<int> &seq) {
  visited[v] = 1;
  for (int u : path[v]) {
    if (!visited[u]) {
      seq.push_back(u);
      dfs(u, visited, path, seq);
    }
  }
}
void countfn(int v, vector<bool> &counted, vector<int> &count,
             vector<vector<int>> &path, vector<int> &p) {
  count[v] = 1;
  for (int u : path[v]) {
    if (u != p[v]) {
      if (counted[u]) {
        count[v] += count[u];
      } else {
        countfn(u, counted, count, path, p);
        count[v] += count[u];
      }
    }
  }
  counted[v] = 1;
}
int main() {
  int n, q;
  cin >> n >> q;
  vector<int> p(n + 1);
  vector<vector<int>> path(n + 1);
  for (int i = 2; i <= n; i++) {
    cin >> p[i];
    path[i].push_back(p[i]);
    path[p[i]].push_back(i);
  }
  p[1] = 0;
  for (int i = 1; i <= n; i++) {
    sort(path[i].begin(), path[i].end());
  }
  vector<int> seq;
  vector<bool> visited(n + 1, 0);
  seq.push_back(1);
  dfs(1, visited, path, seq);
  vector<int> count(n + 1);
  vector<bool> counted(n + 1, 0);
  for (int i = 2; i <= n; i++) {
    if (path[i].size() == 1) {
      count[i] = 1;
      counted[i] = 1;
    }
  }
  countfn(1, counted, count, path, p);
  vector<int> pos(n + 1);
  for (int i = 0; i < n; i++) {
    pos[seq[i]] = i;
  }
  while (q--) {
    int u, k;
    cin >> u >> k;
    if (k > count[u])
      cout << -1 << endl;
    else {
      int i = pos[u];
      cout << seq[i - 1 + k] << endl;
    }
  }
}
