#include <bits/stdc++.h>
using namespace std;
vector<int> trav;
int child[200002];
int dfs(int a, vector<vector<int>> &gr) {
  trav.push_back(a);
  int z = 0;
  for (auto it = gr[a].begin(); it != gr[a].end(); it++) {
    z = z + dfs(*it, gr);
  }
  child[a] = z + 1;
  return z + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a, q, ar[200002];
  vector<vector<int>> gr(200002);
  cin >> n >> q;
  for (int i = 2; i <= n; i++) {
    cin >> a;
    gr[a].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    sort(gr[i].begin(), gr[i].end());
  }
  dfs(1, gr);
  int ix = 0;
  for (auto it = trav.begin(); it != trav.end(); it++) {
    ar[*it] = ix++;
  }
  int u, k;
  child[1] = n;
  for (int i = 0; i < q; i++) {
    cin >> u >> k;
    if (child[u] < k) {
      cout << "-1";
    } else {
      cout << trav[ar[u] + k - 1];
    }
    cout << "\n";
  }
  return 0;
}
