In the NN country, there are n cities, numbered from 1 to n, and n - 1 roads, connecting them. There is a roads path between any two cities.

There are m bidirectional bus routes between cities. Buses drive between two cities taking the shortest path with stops in every city they drive through. Travelling by bus, you can travel from any stop on the route to any other. You can travel between cities only by bus.

You are interested in q questions: is it possible to get from one city to another and what is the minimum number of buses you need to use for it?

Input

The first line contains a single integer n (2 ≤ n ≤ 2 ⋅ 10^5) — the number of cities.

The second line contains n - 1 integers p_2, p_3, …, p_n (1 ≤ p_i < i), where p_i means that cities p_i and i are connected by road.

The third line contains a single integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of bus routes.

Each of the next m lines contains 2 integers a and b (1 ≤ a, b ≤ n, a ≠ b), meaning that there is a bus route between cities a and b. It is possible that there is more than one route between two cities.

The next line contains a single integer q (1 ≤ q ≤ 2 ⋅ 10^5) — the number of questions you are interested in.

Each of the next q lines contains 2 integers v and u (1 ≤ v, u ≤ n, v ≠ u), meaning that you are interested if it is possible to get from city v to city u and what is the minimum number of buses you need to use for it.

Output

Print the answer for each question on a separate line. If there is no way to get from one city to another, print -1. Otherwise print the minimum number of buses you have to use.

Examples

Input

7
1 1 1 4 5 6
4
4 2
5 4
1 3
6 7
6
4 5
3 5
7 2
4 5
3 2
5 3


Output

1
3
-1
1
2
3


Input

7
1 1 2 3 4 1
4
4 7
3 5
7 6
7 6
6
4 6
3 1
3 2
2 7
6 3
5 3


Output

1
-1
-1
1
-1
1

Note

<image> Routes for first sample are marked on the picture. 
#include <bits/stdc++.h>
using namespace std;
int n;
int par[200009], in[200009], ou[200009], spt[200009][22], dep[200009],
    up[200009];
pair<int, int> pr[200009];
int bup[200009][22];
int ans[200009];
vector<int> al[200009];
int tim;
vector<pair<pair<int, int>, int> > qu;
void dfs_p(int x, int p) {
  dep[x] = dep[p] + 1;
  for (int i = 0; i < (int)al[x].size(); i++) dfs_p(al[x][i], x);
}
void lca_init() {
  int root = 1;
  dep[root] = -1;
  dfs_p(root, root);
  for (int l = 0; l < 22; l++) {
    for (int i = 1; i <= n; i++) {
      if (l == 0) {
        spt[i][l] = par[i];
        continue;
      }
      spt[i][l] = spt[spt[i][l - 1]][l - 1];
    }
  }
}
int lca(int u, int v) {
  if (u == v) return u;
  if (dep[u] < dep[v]) return lca(v, u);
  for (int i = 22 - 1; i >= 0; i--) {
    if (dep[spt[u][i]] >= dep[v]) u = spt[u][i];
  }
  for (int i = 22 - 1; i >= 0; i--)
    if (spt[u][i] != spt[v][i]) {
      u = spt[u][i];
      v = spt[v][i];
    }
  return u == v ? u : spt[u][0];
}
void dfs(int v) {
  in[v] = tim++;
  int m = al[v].size();
  int p = v;
  for (int i = 0; i < m; i++) {
    int u = al[v][i];
    dfs(u);
    if (dep[bup[u][0]] < dep[p]) p = bup[u][0];
  }
  if (up[v] != 0 && dep[up[v]] < dep[p]) p = up[v];
  bup[v][0] = p;
  ou[v] = tim++;
}
int f1(int v, int l) {
  int i = 22 - 1;
  int ret = 0;
  while (i >= 0) {
    int u = bup[v][i];
    if (dep[u] > dep[l]) {
      ret += (1 << i);
      v = u;
    }
    i--;
  }
  if (v != l) {
    ret++;
    v = bup[v][0];
  }
  if (dep[v] > dep[l]) return -1;
  return ret;
}
int f2(int u, int r) {
  int i = 22 - 1;
  while (i >= 0) {
    if (1 << i <= r) {
      u = bup[u][i];
    }
    i--;
  }
  return u;
}
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return ou[a.first.second] < ou[b.first.second];
}
bool cmp2(pair<int, int> a, pair<int, int> b) {
  return in[a.second] < in[b.second];
}
struct node {
  int si, ei;
  int v, lz;
  node(int sii, int eii, int vv) {
    si = sii;
    ei = eii;
    v = vv;
  }
  node() { si = ei = v = 0; }
};
struct seg_tree {
  node nd[8 * 200009];
  void init(int in, int s, int e) {
    node &n = nd[in];
    if (s == e) {
      n = node(s, e, -1);
      return;
    }
    int mid = (s + e) / 2;
    init(2 * in, s, mid);
    init(2 * in + 1, mid + 1, e);
    n = merge(nd[2 * in], nd[2 * in + 1]);
  }
  node merge(node a, node b) { return node(a.si, b.ei, max(a.v, b.v)); }
  void upd_nd(node &n, int v) { n.v = max(n.v, v); }
  node query_r(int in, int s, int e) {
    node &n = nd[in];
    if (n.si == s && n.ei == e) return n;
    int mid = (n.si + n.ei) / 2;
    if (e <= mid)
      return query_r(2 * in, s, e);
    else if (s > mid)
      return query_r(2 * in + 1, s, e);
    else
      return merge(query_r(2 * in, s, mid), query_r(2 * in + 1, mid + 1, e));
  }
  void update_p(int in, int i, int v) {
    node &n = nd[in];
    if (n.si == n.ei) {
      upd_nd(n, v);
      return;
    }
    int mid = (n.si + n.ei) / 2;
    if (i <= mid)
      update_p(2 * in, i, v);
    else
      update_p(2 * in + 1, i, v);
    n = merge(nd[2 * in], nd[2 * in + 1]);
  }
};
seg_tree st;
int main() {
  cin >> n;
  par[1] = 1;
  for (int i = 2; i <= n; i++) {
    int a;
    scanf("%d", &a);
    al[a].push_back(i);
    par[i] = a;
  }
  lca_init();
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    int l = lca(u, v);
    if (up[u] == 0 || dep[up[u]] > dep[l]) {
      up[u] = l;
    }
    if (up[v] == 0 || dep[up[v]] > dep[l]) {
      up[v] = l;
    }
    pr[i] = make_pair(u, v);
  }
  tim = 0;
  dfs(1);
  for (int i = 0; i < m; i++) {
    if (in[pr[i].first] > in[pr[i].second]) swap(pr[i].first, pr[i].second);
  }
  for (int i = 1; i < 22; i++) {
    for (int j = 1; j <= n; j++) {
      bup[j][i] = bup[bup[j][i - 1]][i - 1];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    int l = lca(u, v);
    if (dep[u] > dep[v]) swap(u, v);
    if (u == l) {
      ans[i] = f1(v, u);
      continue;
    }
    int u1 = f1(u, l);
    int v1 = f1(v, l);
    if (u1 == -1 || v1 == -1) {
      ans[i] = -1;
    } else {
      ans[i] = u1 + v1;
      u1 = f2(u, u1 - 1);
      v1 = f2(v, v1 - 1);
      if (in[u1] > in[v1]) swap(u1, v1);
      qu.push_back(make_pair(make_pair(u1, v1), i));
    }
  }
  sort(qu.begin(), qu.end(), cmp);
  sort(pr, pr + m, cmp2);
  int qs = qu.size();
  st.init(1, 0, tim);
  int ii = 0;
  for (int i = 0; i < qs; i++) {
    int u = qu[i].first.first, v = qu[i].first.second;
    int j = qu[i].second;
    while (ii < m && in[pr[ii].second] <= ou[v]) {
      st.update_p(1, in[pr[ii].first], in[pr[ii].second]);
      ii++;
    }
    int x = st.query_r(1, in[u], ou[u]).v;
    if (x >= in[v]) {
      ans[j]--;
    }
  }
  for (int i = 0; i < q; i++) cout << ans[i] << endl;
}
