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;
const int N = 200005;
int n, m, q, t, tt, a[N], dfn[N], r[N], dep[N], fa[N][25], f[N][25], qq[N][2],
    rt[N], s[N * 20], ls[N * 20], rs[N * 20], ans[N], ff[N];
pair<int, int> e[N];
vector<int> g[N];
void dfs1(int x, int p) {
  dfn[x] = ++t;
  fa[x][0] = p;
  dep[x] = dep[p] + 1;
  for (int i = 0; i < g[x].size(); i++) dfs1(g[x][i], x);
  r[x] = t;
}
void dfs2(int x) {
  for (int i = 0; i < g[x].size(); i++) {
    dfs2(g[x][i]);
    f[x][0] = (dep[f[g[x][i]][0]] > dep[f[x][0]] ? f[x][0] : f[g[x][i]][0]);
  }
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int sub = dep[x] - dep[y];
  for (int i = 0; i <= 20; i++)
    if (sub & (1 << i)) x = fa[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int gtdis(int x, int y, int id, int kd) {
  int s = 0;
  for (int i = 20; i >= 0; i--)
    if (dep[f[x][i]] > dep[y]) s |= (1 << i), x = f[x][i];
  qq[id][kd] = x;
  return s;
}
bool cmp(pair<int, int> a, pair<int, int> b) {
  return dfn[a.first] < dfn[b.first];
}
void ins(int &x, int y, int l, int r, int p) {
  x = ++tt;
  s[x] = s[y] + 1;
  if (l == r) return;
  int md = l + r >> 1;
  if (p <= md)
    rs[x] = rs[y], ins(ls[x], ls[y], l, md, p);
  else
    ls[x] = ls[y], ins(rs[x], rs[y], md + 1, r, p);
}
int qry(int x, int y, int l, int r, int tl, int tr) {
  if (tl <= l && r <= tr) return s[y] - s[x];
  int md = l + r >> 1, res = 0;
  if (tl <= md) res += qry(ls[x], ls[y], l, md, tl, tr);
  if (tr > md) res += qry(rs[x], rs[y], md + 1, r, tl, tr);
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 2, p; i <= n; i++) {
    scanf("%d", &p);
    g[p].push_back(i);
  }
  dfs1(1, 0);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];
  for (int i = 1; i <= n; i++) f[i][0] = i;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    int t = lca(u, v);
    e[i] = make_pair(u, v);
    if (dep[f[u][0]] > dep[t]) f[u][0] = t;
    if (dep[f[v][0]] > dep[t]) f[v][0] = t;
  }
  dfs2(1);
  for (int i = 1; i <= 20; i++)
    for (int j = 1; j <= n; j++) f[j][i] = f[f[j][i - 1]][i - 1];
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    int t = lca(u, v);
    if (dep[f[u][20]] > dep[t] || dep[f[v][20]] > dep[t])
      ans[i] = -1;
    else {
      if (u == t)
        ff[i] = 1, ans[i] = gtdis(v, t, i, 0) + 1;
      else if (v == t)
        ff[i] = 1, ans[i] = gtdis(u, t, i, 0) + 1;
      else
        ans[i] = gtdis(u, t, i, 0) + gtdis(v, t, i, 1) + 1;
    }
  }
  sort(e + 1, e + m + 1, cmp);
  for (int i = 1; i <= m; i++) a[i] = dfn[e[i].first];
  for (int i = 1; i <= m; i++) ins(rt[i], rt[i - 1], 1, n, dfn[e[i].second]);
  for (int i = 1; i <= q; i++) {
    if (ans[i] == -1 || ff[i] == 1) continue;
    int pl = lower_bound(a + 1, a + m + 1, dfn[qq[i][0]]) - a - 1;
    int pr = lower_bound(a + 1, a + m + 1, r[qq[i][0]] + 1) - a - 1;
    int res1 = qry(rt[pl], rt[pr], 1, n, dfn[qq[i][1]], r[qq[i][1]]);
    pl = lower_bound(a + 1, a + m + 1, dfn[qq[i][1]]) - a - 1;
    pr = lower_bound(a + 1, a + m + 1, r[qq[i][1]] + 1) - a - 1;
    int res2 = qry(rt[pl], rt[pr], 1, n, dfn[qq[i][0]], r[qq[i][0]]);
    if (res1 == 0 && res2 == 0) ans[i]++;
  }
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
