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 read() {
  int x = 0;
  bool flg = false;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') flg = true;
  for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^ 48);
  return flg ? -x : x;
}
int n, m, q;
struct Edge {
  int to, nxt;
} edge[200010];
int cnt, last[200010];
inline void addedge(int x, int y) {
  edge[++cnt] = (Edge){y, last[x]}, last[x] = cnt;
}
int fat[200010], siz[200010], son[200010], dep[200010];
int top[200010], id[200010];
void dfs1(int cur, int fat, int dep) {
  ::fat[cur] = fat;
  ::dep[cur] = dep;
  siz[cur] = 1;
  for (int i = last[cur]; i; i = edge[i].nxt) {
    dfs1(edge[i].to, cur, dep + 1);
    siz[cur] += siz[edge[i].to];
    if (!son[cur] || siz[son[cur]] < siz[edge[i].to]) son[cur] = edge[i].to;
  }
}
void dfs2(int cur, int top) {
  ::top[cur] = top;
  id[cur] = ++*id;
  if (siz[cur] == 1) return;
  dfs2(son[cur], top);
  for (int i = last[cur]; i; i = edge[i].nxt)
    if (edge[i].to ^ son[cur]) dfs2(edge[i].to, edge[i].to);
}
int getlca(int x, int y) {
  while (top[x] ^ top[y])
    if (dep[top[x]] < dep[top[y]])
      y = fat[top[y]];
    else
      x = fat[top[x]];
  if (dep[x] < dep[y]) return x;
  return y;
}
namespace B {
struct Edge {
  int to, nxt;
} edge[400010];
int cnt, last[200010];
inline void addedge(int x, int y) {
  edge[++cnt] = (Edge){y, last[x]}, last[x] = cnt;
}
int gnd[200010][18], maxdep[200010];
void dfs3(int cur) {
  maxdep[cur] = cur;
  for (int i = last[cur]; i; i = edge[i].nxt)
    if (dep[edge[i].to] < dep[maxdep[cur]]) maxdep[cur] = edge[i].to;
  for (int i = ::last[cur]; i; i = ::edge[i].nxt) {
    dfs3(::edge[i].to);
    if (dep[maxdep[::edge[i].to]] < dep[maxdep[cur]])
      maxdep[cur] = maxdep[::edge[i].to];
  }
}
void dfs4(int cur) {
  if (maxdep[cur] ^ cur) {
    gnd[cur][0] = maxdep[cur];
    for (int i = 1; i < 18 && gnd[cur][i - 1]; i++)
      gnd[cur][i] = gnd[gnd[cur][i - 1]][i - 1];
  }
  for (int i = ::last[cur]; i; i = ::edge[i].nxt) dfs4(::edge[i].to);
}
}  // namespace B
using B::gnd;
using B::maxdep;
int ans[200010];
int subans[200010];
bool mrk[200010];
namespace R {
struct Edge {
  int pos, opt, l, r, nxt;
} edge[800010];
int cnt, last1[200010], last2[200010];
inline void addedge(int *last, int x, int pos, int opt, int l, int r) {
  edge[++cnt] = (Edge){pos, opt, l, r, last[x]}, last[x] = cnt;
}
int tri[200010];
void add(int x) {
  for (; x <= n; x += x & -x) tri[x]++;
}
int query(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += tri[x];
  return res;
}
void solve() {
  for (int i = 1; i <= n; i++) {
    for (int j = last2[i]; j; j = edge[j].nxt) add(edge[j].pos);
    for (int j = last1[i]; j; j = edge[j].nxt)
      subans[edge[j].pos] +=
          edge[j].opt * (query(edge[j].r) - query(edge[j].l - 1));
  }
}
}  // namespace R
using R::last1;
using R::last2;
int main() {
  n = read();
  for (int i = 2; i <= n; i++) addedge(read(), i);
  dfs1(1, 0, 1);
  dfs2(1, 1);
  m = read();
  for (int i = 1, x, y, z; i <= m; i++) {
    x = read(), y = read(), z = getlca(x, y);
    B::addedge(x, z);
    B::addedge(y, z);
    R::addedge(last2, id[x], id[y], 0, 0, 0);
    R::addedge(last2, id[y], id[x], 0, 0, 0);
  }
  B::dfs3(1);
  B::dfs4(1);
  q = read();
  for (int i = 1, x, y, z, a, b; i <= q; i++) {
    x = read(), y = read();
    z = getlca(x, y);
    if (dep[x] > dep[y]) swap(x, y);
    if (x == z) {
      for (int j = 17; j >= 0; j--) {
        if (!gnd[y][j]) continue;
        if (dep[gnd[y][j]] > dep[x]) y = gnd[y][j], ans[i] += (1 << j);
      }
      if (!gnd[y][0]) {
        ans[i] = -1;
        continue;
      }
      y = gnd[y][0], ans[i]++;
      if (dep[y] > dep[x]) {
        ans[i] = -1;
        continue;
      }
      continue;
    }
    a = x, b = y;
    bool flg1 = false, flg2 = false;
    for (int j = 17; j >= 0; j--) {
      if (!gnd[a][j]) continue;
      if (dep[gnd[a][j]] <= dep[z]) flg1 = true;
      if (dep[gnd[a][j]] > dep[z]) a = gnd[a][j], ans[i] += (1 << j);
    }
    if (!flg1) {
      ans[i] = -1;
      continue;
    }
    for (int j = 17; j >= 0; j--) {
      if (!gnd[b][j]) continue;
      if (dep[gnd[b][j]] <= dep[z]) flg2 = true;
      if (dep[gnd[b][j]] > dep[z]) b = gnd[b][j], ans[i] += (1 << j);
    }
    if (!flg2) {
      ans[i] = -1;
      continue;
    }
    R::addedge(last1, id[a] - 1, i, -1, id[b], id[b] + siz[b] - 1);
    R::addedge(last1, id[a] + siz[a] - 1, i, 1, id[b], id[b] + siz[b] - 1);
    mrk[i] = true;
    ans[i] += 2;
  }
  R::solve();
  for (int i = 1; i <= q; i++) {
    if (mrk[i] && subans[i]) ans[i]--;
    printf("%d\n", ans[i]);
  }
  return 0;
}