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;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * w;
}
struct edge {
  int v, nxt;
} e[200010 << 1];
int n, m, q, cnt, tot;
int head[200010], fa[200010], size[200010], son[200010], top[200010],
    dfn[200010], dep[200010], out[200010];
int f[200010][21], up[200010], p[21], ans[200010], c[200010];
vector<int> E[200010];
vector<pair<int, int> > Q[200010];
int lowbit(int x) { return x & -x; }
void Add(int x, int val) {
  for (int i = x; i <= n; i += lowbit(i)) c[i] += val;
}
int query(int x) {
  int res = 0;
  for (int i = x; i >= 1; i -= lowbit(i)) res += c[i];
  return res;
}
void add(int u, int v) { e[++cnt].v = v, e[cnt].nxt = head[u], head[u] = cnt; }
void dfs1(int u, int ff) {
  out[u] = dfn[u] = ++tot, size[u] = 1, fa[u] = ff, dep[u] = dep[ff] + 1;
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != ff) {
      dfs1(e[i].v, u);
      size[u] += size[e[i].v], out[u] = max(out[u], out[e[i].v]);
      if (size[e[i].v] > size[son[u]]) son[u] = e[i].v;
    }
}
void dfs2(int u, int topf) {
  top[u] = topf;
  if (son[u]) dfs2(son[u], topf);
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (!top[e[i].v]) dfs2(e[i].v, e[i].v);
}
int LCA(int x, int y) {
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    x = fa[top[x]];
  }
  return dep[x] < dep[y] ? x : y;
}
void dfs3(int u, int ff) {
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != ff) {
      dfs3(e[i].v, u);
      if (f[e[i].v][1] != 0 &&
          (dep[f[e[i].v][1]] < dep[f[u][1]] || f[u][1] == 0))
        f[u][1] = f[e[i].v][1];
    }
}
void dfs4(int u, int ff) {
  for (int i = 2; i <= 20; i++) f[u][i] = f[f[u][i - 1]][i - 1];
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != ff) dfs4(e[i].v, u);
}
bool check(int u, int pos) {
  for (int i = 20; i >= 0; i--)
    if (dep[f[u][i]] <= dep[pos] && f[u][i] != 0) return 1;
  return 0;
}
pair<int, int> get(int u, int pos) {
  int dis = 0;
  if (!check(u, pos)) return make_pair(0, -0x3f3f3f3f);
  for (int i = 20; i >= 1; i--)
    if (dep[f[u][i]] > dep[pos] && f[u][i] != 0) u = f[u][i], dis += p[i - 1];
  return make_pair(u, dis);
}
void dfs(int u, int ff) {
  vector<int> Num;
  for (pair<int, int> x : Q[u])
    Num.push_back(query(out[x.first]) - query(dfn[x.first] - 1));
  for (int x : E[u]) Add(dfn[x], 1);
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != ff) dfs(e[i].v, u);
  for (int i = 0; i < Q[u].size(); i++) {
    pair<int, int> x = Q[u][i];
    if (query(out[x.first]) - query(dfn[x.first] - 1) != Num[i])
      ans[x.second]--;
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) {
    int p = read();
    add(p, i), add(i, p);
  }
  dfs1(1, 0), dfs2(1, 1);
  for (int i = 1; i <= n; i++) f[i][0] = i;
  p[0] = 1;
  for (int i = 1; i <= 20; i++) p[i] = p[i - 1] << 1;
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    if (dfn[x] > dfn[y]) swap(x, y);
    E[x].push_back(y);
    int lca = LCA(x, y);
    if (dep[lca] < dep[f[x][1]] || !f[x][1]) f[x][1] = lca;
    if (dep[lca] < dep[f[y][1]] || !f[y][1]) f[y][1] = lca;
  }
  dfs3(1, 0), dfs4(1, 0);
  q = read();
  for (int i = 1; i <= q; i++) {
    int x = read(), y = read(), lca = LCA(x, y);
    if (lca == x || lca == y) {
      if (x == lca) swap(x, y);
      pair<int, int> tmp = get(x, y);
      ans[i] = tmp.second + 1 - 2;
      continue;
    }
    pair<int, int> tmp = get(x, lca);
    ans[i] += tmp.second, x = tmp.first;
    tmp = get(y, lca);
    ans[i] += tmp.second, y = tmp.first;
    if (!x || !y) continue;
    if (dfn[x] > dfn[y]) swap(x, y);
    Q[x].push_back(make_pair(y, i));
  }
  for (int i = 1; i <= q; i++) ans[i] += 2;
  dfs(1, 0);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i] < 0 ? -1 : ans[i]);
  return 0;
}