#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589;
const long long int zero = 0;
long long int mod = 1000000007;
char al[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
               'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
vector<int> order;
vector<int> parenthood[200000];
int cnt[200000];
void dfs(int w) {
  order.push_back(w);
  cnt[w - 1] = 1;
  vector<int>::iterator it;
  for (it = parenthood[w - 1].begin(); it != parenthood[w - 1].end(); it++) {
    dfs(*it);
    cnt[w - 1] += cnt[*it - 1];
  }
}
int main() {
  int t = 1;
  while (t--) {
    int n, q, p, a, b;
    cin >> n >> q;
    for (long long int i = 0; i < n - 1; i++) {
      cin >> p;
      parenthood[p - 1].push_back(i + 2);
    }
    for (long long int i = 0; i < n; i++) {
      cnt[i] = 0;
    }
    dfs(1);
    int index[n];
    for (long long int i = 0; i < n; i++) {
      index[order[i] - 1] = i;
    }
    for (long long int i = 0; i < q; i++) {
      cin >> a >> b;
      if (b > cnt[a - 1]) {
        cout << -1 << endl;
      } else {
        cout << order[index[a - 1] + b - 1] << endl;
      }
    }
  }
}
