#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 10;
const long long MOD = 1e9 + 7;
bool func(pair<long long, long long> A, pair<long long, long long> B) {
  return A.second < B.second;
}
vector<long long> cc(2 * 100000 + 5);
vector<long long> vec[2 * 100000 + 5];
vector<long long> flag(2 * 100000 + 5);
vector<long long> res;
void dfs(long long st) {
  res.push_back(st);
  flag[st] = 1;
  cc[st]++;
  for (auto x : vec[st]) {
    if (!flag[x]) {
      dfs(x);
      cc[st] += cc[x];
    }
  }
}
void solve() {
  long long n, q;
  cin >> n >> q;
  for (long long i = 0; i < n - 1; i += 1) {
    long long num;
    cin >> num;
    vec[num].push_back(i + 2);
    vec[i + 2].push_back(num);
  }
  dfs(1);
  vector<long long> skip(2 * 100000 + 5);
  for (long long i = 0; i < n; i += 1) {
    skip[res[i]] = i;
  }
  while (q--) {
    long long u, k;
    cin >> u >> k;
    if (cc[u] < k)
      cout << "-1\n";
    else
      cout << res[skip[u] + k - 1] << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  { solve(); }
  return 0;
}
