#include <bits/stdc++.h>
using namespace std;
long long constructSizes(long long n, vector<long long> &sizes,
                         vector<vector<long long>> &adj, long long node,
                         vector<long long> &preorder) {
  preorder.push_back(node);
  if (adj[node].empty()) {
    return 1;
  } else {
    long long sz = 1;
    sort(adj[node].begin(), adj[node].end());
    for (long long next : adj[node])
      sz += constructSizes(n, sizes, adj, next, preorder);
    return sizes[node] = sz;
  }
}
void solveCase() {
  long long n, q;
  cin >> n >> q;
  vector<vector<long long>> adj(n);
  vector<long long> sizes(n, 1), preorder;
  for (long long i = 0; i < (n - 1); i++) {
    long long pin;
    cin >> pin;
    pin--;
    adj[pin].push_back(i + 1);
  }
  constructSizes(n, sizes, adj, 0, preorder);
  vector<long long> poses(n, 0);
  for (long long i = 0; i < (n); i++) {
    poses[preorder[i]] = i;
  }
  for (long long i = 0; i < (q); i++) {
    long long u, k;
    cin >> u >> k;
    u--;
    if (sizes[u] >= k) {
      cout << preorder[poses[u] + k - 1] + 1;
      cout << "\n";
    } else
      cout << "-1\n";
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  { solveCase(); }
  return 0;
}
