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 x = 0, f = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') f = -1;
  } while (ch < '0' || ch > '9');
  do {
    x = x * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return x * f;
}
const int N = 200010, LOG = 19;
struct node {
  int u, v, next;
} edge[N << 1];
int last[N], le;
void add(int u, int v) {
  edge[++le].u = u, edge[le].v = v, edge[le].next = last[u], last[u] = le;
  edge[++le].u = v, edge[le].v = u, edge[le].next = last[v], last[v] = le;
}
int dp[LOG][N], deep[N], pre[N], nxt[N], tp[LOG][N], lt, n, m, tans[N];
vector<int> G1[N], G2[N], Gnum[N], lans[N];
void dfs1(int u, int fa) {
  pre[u] = ++lt, deep[u] = deep[fa] + 1;
  for (int i = last[u]; i; i = edge[i].next) {
    int v = edge[i].v;
    if (v == fa) continue;
    dfs1(v, u);
  }
  nxt[u] = lt;
}
void getdp() {
  for (int i = 1; i < LOG; ++i) {
    for (int j = 1; j <= n; ++j) dp[i][j] = dp[i - 1][dp[i - 1][j]];
  }
}
void gettp() {
  for (int i = 1; i < LOG; ++i) {
    for (int j = 1; j <= n; ++j) tp[i][j] = tp[i - 1][tp[i - 1][j]];
  }
}
int getlca(int u, int v) {
  if (deep[u] < deep[v]) swap(u, v);
  for (int i = LOG - 1; ~i; --i)
    if (deep[dp[i][u]] >= deep[v]) u = dp[i][u];
  if (u == v) return u;
  for (int i = LOG - 1; ~i; --i)
    if (dp[i][u] != dp[i][v]) u = dp[i][u], v = dp[i][v];
  return dp[0][u];
}
int sumv[N << 2];
inline void pushup(int o) { sumv[o] = sumv[o << 1] + sumv[o << 1 | 1]; }
void qadd(int o, int l, int r, int x, int v) {
  if (l == r) {
    sumv[o] += v;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    qadd(o << 1, l, mid, x, v);
  else
    qadd(o << 1 | 1, mid + 1, r, x, v);
  pushup(o);
}
int qsum(int o, int l, int r, int x, int y) {
  if (x <= l && r <= y) return sumv[o];
  int mid = (l + r) >> 1;
  if (y <= mid)
    return qsum(o << 1, l, mid, x, y);
  else if (x > mid)
    return qsum(o << 1 | 1, mid + 1, r, x, y);
  else
    return qsum(o << 1, l, mid, x, mid) +
           qsum(o << 1 | 1, mid + 1, r, mid + 1, y);
}
void dfs2(int u, int fa) {
  lans[u].resize(G2[u].size());
  for (int i = G2[u].size() - 1; ~i; --i) {
    int v = G2[u][i];
    lans[u][i] = qsum(1, 1, lt, pre[v], nxt[v]);
  }
  for (int i = G1[u].size() - 1; ~i; --i) {
    int v = G1[u][i];
    qadd(1, 1, lt, pre[v], 1);
  }
  for (int i = last[u]; i; i = edge[i].next) {
    int v = edge[i].v;
    if (v == fa) continue;
    dfs2(v, u);
  }
  for (int i = G2[u].size() - 1; ~i; --i) {
    int v = G2[u][i];
    if (qsum(1, 1, lt, pre[v], nxt[v]) == lans[u][i]) ++tans[Gnum[u][i]];
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) tp[0][i] = i;
  for (int i = 2; i <= n; ++i) {
    dp[0][i] = read();
    add(dp[0][i], i);
  }
  dfs1(1, 0);
  getdp();
  m = read();
  while (m--) {
    int u = read(), v = read(), lca = getlca(u, v);
    tp[0][u] = min(tp[0][u], lca);
    tp[0][v] = min(tp[0][v], lca);
    if (pre[u] > pre[v]) swap(u, v);
    G1[u].push_back(v);
  }
  for (int i = n; i; --i) tp[0][dp[0][i]] = min(tp[0][dp[0][i]], tp[0][i]);
  gettp();
  int q = read();
  for (int i = 1; i <= q; ++i) {
    int u = read(), v = read(), lca = getlca(u, v);
    tans[i] = 1;
    for (int j = LOG - 1; ~j; --j)
      if (deep[tp[j][u]] > deep[lca]) tans[i] += (1 << j), u = tp[j][u];
    for (int j = LOG - 1; ~j; --j)
      if (deep[tp[j][v]] > deep[lca]) tans[i] += (1 << j), v = tp[j][v];
    if (deep[tp[0][u]] > deep[lca] || deep[tp[0][v]] > deep[lca])
      tans[i] = -1;
    else if (u != lca && v != lca) {
      if (pre[u] > pre[v]) swap(u, v);
      G2[u].push_back(v);
      Gnum[u].push_back(i);
    }
  }
  dfs2(1, 0);
  for (int i = 1; i <= q; ++i) printf("%d\n", tans[i]);
  return 0;
}