Problem: 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. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int pre[400005], to[400005], las[400005], inc;
int fa[400005][21], jmp[400005][21], dep[400005], dfn[400005], out[400005], dft;
int n, m, q, ans[400005];
void ins(int a, int b) {
  pre[++inc] = las[a];
  las[a] = inc, to[inc] = b;
}
void dfs(int x, int par) {
  fa[x][0] = par, dfn[x] = ++dft, dep[x] = dep[par] + 1;
  for (int i = 1; i <= 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = las[x]; i; i = pre[i])
    if (to[i] != par) dfs(to[i], x);
  out[x] = dft;
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20, delta = dep[x] - dep[y]; i >= 0; i--)
    if (delta >> i & 1) 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];
}
void GetJmp1(int x) {
  for (int i = las[x]; i; i = pre[i]) {
    int y = to[i];
    GetJmp1(y);
    if (!jmp[x][0] || (dep[jmp[x][0]] > dep[jmp[y][0]] && jmp[y][0]))
      jmp[x][0] = jmp[y][0];
  }
}
void GetJmp2(int x) {
  for (int i = 1; i <= 20; i++) jmp[x][i] = jmp[jmp[x][i - 1]][i - 1];
  for (int i = las[x]; i; i = pre[i]) GetJmp2(to[i]);
}
int C[400005];
void Add(int x, int v) {
  for (int i = x; i < 400005; i += (i & -i)) C[i] += v;
}
int Query(int x) {
  int ret = 0;
  for (int i = x; i; i ^= (i & -i)) ret += C[i];
  return ret;
}
struct node {
  int x, l, r, ty, id;
} op[400005 * 4];
int tot, sm[400005 * 4];
int cmp(node a, node b) { return a.x == b.x ? a.ty < b.ty : a.x < b.x; }
int main() {
  scanf("%d", &n);
  for (int i = 2, x; i <= n; i++) scanf("%d", &x), ins(x, i);
  dfs(1, 0);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y, anc;
    scanf("%d%d", &x, &y), anc = LCA(x, y);
    if (!jmp[x][0] || dep[jmp[x][0]] > dep[anc]) jmp[x][0] = anc;
    if (!jmp[y][0] || dep[jmp[y][0]] > dep[anc]) jmp[y][0] = anc;
    op[++tot] = (node){dfn[x], dfn[y], 0, 0, 0};
    op[++tot] = (node){dfn[y], dfn[x], 0, 0, 0};
  }
  GetJmp1(1), GetJmp2(1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x, y, anc;
    scanf("%d%d", &x, &y), anc = LCA(x, y);
    if (anc == x || anc == y) {
      int p = (anc == x ? y : x);
      for (int j = 20; j >= 0; j--)
        if (jmp[p][j] && dep[jmp[p][j]] > dep[anc])
          p = jmp[p][j], ans[i] += (1 << j);
      if (!jmp[p][0] || dep[jmp[p][0]] > dep[anc]) ans[i] = -1;
    } else {
      for (int j = 20; j >= 0; j--)
        if (jmp[x][j] && dep[jmp[x][j]] > dep[anc])
          x = jmp[x][j], ans[i] += (1 << j);
      for (int j = 20; j >= 0; j--)
        if (jmp[y][j] && dep[jmp[y][j]] > dep[anc])
          y = jmp[y][j], ans[i] += (1 << j);
      ans[i]++;
      if (!jmp[x][0] || !jmp[y][0] || dep[jmp[x][0]] > dep[anc] ||
          dep[jmp[y][0]] > dep[anc])
        ans[i] = -1;
      op[++tot] = (node){dfn[x], dfn[y], out[y], -1, i},
      op[++tot] = (node){out[x], dfn[y], out[y], 1, i};
    }
  }
  sort(op + 1, op + tot + 1, cmp);
  for (int i = 1; i <= tot; i++) {
    if (op[i].ty == -1) sm[op[i].id] = Query(op[i].r) - Query(op[i].l - 1);
    if (op[i].ty == 0) Add(op[i].l, 1);
    if (op[i].ty == 1)
      sm[op[i].id] = Query(op[i].r) - Query(op[i].l - 1) - sm[op[i].id];
  }
  for (int i = 1; i <= q; i++) {
    if (ans[i] == -1)
      printf("-1\n");
    else
      printf("%d\n", ans[i] - (sm[i] > 0) + 1);
  }
  return 0;
}