#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 5;
vector<long long int> g[N];
long long int siz[N];
vector<long long int> order;
map<long long int, long long int> mp;
long long int timer;
void dfs(long long int node, long long int p) {
  siz[node] = 1;
  timer++;
  mp[node] = timer;
  order.push_back(node);
  for (long long int x : g[node])
    if (x != p) {
      dfs(x, node);
      siz[node] += siz[x];
    }
  return;
}
signed main() {
  long long int t = 1;
  while (t--) {
    long long int n, q;
    cin >> n >> q;
    for (long long int i = 2; i <= n; i++) {
      long long int x;
      cin >> x;
      g[i].push_back(x);
      g[x].push_back(i);
    }
    dfs(1, 0);
    while (q--) {
      long long int u, k;
      cin >> u >> k;
      if (siz[u] < k) {
        cout << -1 << endl;
      } else {
        long long int index = mp[u];
        --index, --k;
        cout << order[index + k] << endl;
      }
    }
  }
}
