#include <bits/stdc++.h>
using namespace std;
const long double EPS = 1e-16;
const int MOD = 1e9 + 7;
const int OO = 1e9;
const int N = 1e5 + 5;
vector<int> g[2 * N];
bool vis[2 * N];
int n;
int a[2 * N], b[2 * N];
vector<int> v;
int dfs(int node) {
  vis[node] = 1;
  v.push_back(node);
  a[node] = v.size() - 1;
  b[node] = 1;
  for (int i = 0; i < g[node].size(); ++i) {
    int child = g[node][i];
    if (!vis[child]) b[node] += dfs(child);
  }
  return b[node];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q, x;
  cin >> n >> q;
  for (int i = 1; i < n; ++i) {
    cin >> x;
    g[x - 1].push_back(i);
  }
  dfs(0);
  int u, k;
  while (q--) {
    cin >> u >> k;
    if (k > b[u - 1])
      cout << -1 << endl;
    else {
      int i = a[u - 1];
      cout << v[i + (k - 1)] + 1 << endl;
    }
  }
}
