#include <bits/stdc++.h>
using namespace std;
unsigned GCD(unsigned u, unsigned v) {
  unsigned r;
  while (v != 0) {
    r = u % v;
    u = v;
    v = r;
  }
  return u;
}
struct DSU {
  vector<long long int> deg;
  vector<long long int> par;
  long long int sum;
  DSU() {}
  DSU(long long int n) {
    deg.resize(n, 0);
    par.resize(n, -1);
    sum = n;
  }
  long long int find(long long int x) {
    if (par[x] == -1) return x;
    return par[x] = find(par[x]);
  }
  void uni(long long int x, long long int y) {
    x = find(x);
    y = find(y);
    if ((x != -1 || y != -1) && x == y) return;
    sum--;
    if (deg[x] < deg[y])
      par[x] = y;
    else {
      deg[x] += (deg[x] == deg[y]);
      par[y] = x;
    }
  }
};
long long int mod = 4001, inf = 4e18;
long long int sum = 0;
long long int tmp3 = 0, tmp = 0, tmp2 = 0, comb = 1;
vector<long long int> arr, check, st;
long long int n, m = 0, q;
long long int maxi = 0, mini = inf;
string s2, s;
vector<set<long long int>> g;
long long int high = 0;
long long int dfs(long long int x) {
  high++;
  arr[high] = x;
  check[x] = high;
  for (auto i : g[x])
    if (!check[i]) st[x] += dfs(i);
  return st[x];
}
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  cin >> n >> q;
  g.resize(n), check.resize(n, 0), st.resize(n, 1), arr.resize(n + 1);
  for (int i = 1; i < n; i++) {
    cin >> tmp;
    g[tmp - 1].insert(i);
  }
  dfs(0);
  for (long long int a, b; q--; cout << endl) {
    cin >> a >> b;
    a -= 1;
    if (st[a] < b)
      cout << -1;
    else {
      cout << arr[check[a] + b - 1] + 1;
    }
  }
  return 0;
}
