#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 1LL;
void solve();
void ITO();
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ITO();
  long long t = 1;
  while (t--) solve();
  return 0;
}
void solve() {
  long long n, q;
  cin >> n >> q;
  vector<vector<long long>> adj(n);
  for (long long i = 0; i < n - 1; i++) {
    long long p;
    cin >> p;
    p--;
    adj[p].push_back(i + 1);
  }
  for (auto &x : adj) sort(x.begin(), x.end());
  vector<long long> child(n);
  vector<long long> tra;
  map<long long, long long> m;
  function<void(long long)> dfs = [&](long long v) {
    tra.push_back(v);
    m[v] = tra.size() - 1;
    for (auto u : adj[v]) {
      dfs(u);
      child[v] += child[u];
    }
    child[v]++;
  };
  dfs(0);
  while (q--) {
    long long u, k;
    cin >> u >> k;
    u--;
    long long ind = m[u];
    if (child[u] < k) {
      cout << -1 << "\n";
      continue;
    }
    cout << tra[ind + k - 1] + 1 << "\n";
  }
  cout << "\n";
  return;
}
void ITO() {}
