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>
const int maxn = 200010, maxm = 200010, maxq = 200010;
int n, p[maxn], go[maxn][19], m, a[maxm], b[maxm];
struct edge {
  int to;
  edge* next;
} E[maxn], *fir[maxn];
int fa[maxn], dep[maxn], siz[maxn], son[maxn], top[maxn];
void init(int i) {
  siz[i] = 1;
  for (edge* e = fir[i]; e; e = e->next) {
    fa[e->to] = i;
    dep[e->to] = dep[i] + 1;
    init(e->to);
    if (siz[e->to] > siz[son[i]]) son[i] = e->to;
    siz[i] += siz[e->to];
  }
}
void hld(int i) {
  for (edge* e = fir[i]; e; e = e->next) {
    top[e->to] = e->to == son[i] ? top[i] : e->to;
    hld(e->to);
  }
}
int lca(int i, int j) {
  while (top[i] != top[j])
    dep[top[i]] > dep[top[j]] ? i = fa[top[i]] : j = fa[top[j]];
  return dep[i] < dep[j] ? i : j;
}
int q, qu[maxq], qans[maxq], qtmp[maxq];
std::vector<int> pst[maxn], qst[maxn];
int pre[maxn], pos[maxn], now, B[maxn];
void add(int i) {
  for (; i <= n; i += i & -i) B[i]++;
}
int qry(int i) {
  int s = 0;
  for (; i; i -= i & -i) s += B[i];
  return s;
}
void dfs(int i) {
  pre[i] = ++now;
  for (int j = qst[i].size(); j--;) {
    int id = qst[i][j], u = qu[id];
    if (!pre[u]) {
      qst[u].push_back(id);
      qu[id] = i;
      qst[i][j] = -1;
    } else
      qtmp[id] = qry(pos[u]) - qry(pre[u] - 1);
  }
  for (int j = pst[i].size(); j--;)
    if (pre[pst[i][j]]) add(pre[pst[i][j]]);
  for (edge* e = fir[i]; e; e = e->next) {
    dfs(e->to);
  }
  for (int j = qst[i].size(); j--;) {
    int id = qst[i][j];
    if (id > -1) {
      int u = qu[id], s = qry(pos[u]) - qry(pre[u] - 1) - qtmp[id];
      if (s) qans[id]--;
    }
  }
  pos[i] = now;
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", p + i);
    E[i] = (edge){i, fir[p[i]]};
    fir[p[i]] = E + i;
  }
  init(top[1] = 1);
  hld(1);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) *go[i] = i;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", a + i, b + i);
    int c = lca(a[i], b[i]);
    if (dep[c] < dep[*go[a[i]]]) *go[a[i]] = c;
    if (dep[c] < dep[*go[b[i]]]) *go[b[i]] = c;
    pst[a[i]].push_back(b[i]);
    if (a[i] != b[i]) pst[b[i]].push_back(a[i]);
  }
  for (int i = n; i > 1; i--)
    if (dep[*go[i]] < dep[*go[p[i]]]) *go[p[i]] = *go[i];
  for (int i = 1; i < 19; i++)
    for (int j = 1; j <= n; j++) go[j][i] = go[go[j][i - 1]][i - 1];
  int q;
  scanf("%d", &q);
  for (int id = 0; id < q; id++) {
    int u, v, s = 0;
    scanf("%d%d", &u, &v);
    int c = lca(u, v);
    for (int i = 19; i--;) {
      if (dep[go[u][i]] > dep[c]) s += 1 << i, u = go[u][i];
      if (dep[go[v][i]] > dep[c]) s += 1 << i, v = go[v][i];
    }
    if (dep[*go[u]] > dep[c] || dep[*go[v]] > dep[c])
      s = -1;
    else if (u == c) {
      if (v != c) s++;
    } else if (v == c)
      s++;
    else {
      s += 2;
      qu[id] = u;
      qst[v].push_back(id);
    }
    qans[id] = s;
  }
  dfs(1);
  for (int i = 0; i < q; i++) printf("%d\n", qans[i]);
}