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;
template <typename T>
bool chkmax(T &a, T b) {
  return (a < b) ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, T b) {
  return (a > b) ? a = b, 1 : 0;
}
inline int read() {
  int x = 0, fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
  return x * fh;
}
int n, m, q;
int dp[200005][20];
vector<int> G[200005];
int cnt, dep[200005], dfn[200005], ed[200005], fa[200005][20];
void dfs(int x) {
  dfn[x] = ++cnt;
  for (int v : G[x])
    if (v != fa[x][0]) fa[v][0] = x, dp[v][0] = dep[v] = dep[x] + 1, dfs(v);
  ed[x] = cnt;
}
int A[200005], B[200005];
int a[200005], b[200005];
int c[200005], s[200005];
vector<int> tr[200005];
int t[200005];
int lowbit(int x) { return x & (-x); }
void add(int x) {
  for (; x <= 200000; x += lowbit(x)) ++t[x];
}
int sum(int x) {
  int res = 0;
  for (; x; x -= lowbit(x)) res += t[x];
  return res;
}
int LCA(int x, int y) {
  int k = dep[x] - dep[y], i;
  if (k < 0) k = -k, swap(x, y);
  for (i = 0; k; k >>= 1, ++i)
    if (k & 1) x = fa[x][i];
  if (x == y) return x;
  for (int i = 18; i--;)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void DP(int x) {
  for (int v : G[x]) {
    if (v == fa[x][0]) continue;
    DP(v), dp[x][0] = min(dp[x][0], dp[v][0]);
  }
}
int getans(int x, int y) {
  for (int i = 0; y; y >>= 1, ++i)
    if (y & 1) x = fa[x][i];
  return x;
}
void getdp(int x) {
  for (int v : tr[x]) {
    if (v > 0) s[v] -= sum(ed[b[v]]) - sum(dfn[b[v]] - 1);
  }
  for (int v : tr[x]) {
    if (v < 0) add(dfn[-v]);
  }
  for (int v : G[x])
    if (v != fa[x][0]) getdp(v);
  for (int v : tr[x]) {
    if (v > 0) s[v] += sum(ed[b[v]]) - sum(dfn[b[v]] - 1);
  }
}
int main() {
  n = read();
  for (int i = (2), _end_ = (int)(n); i <= _end_; ++i) {
    int ff = read();
    G[ff].push_back(i);
    G[i].push_back(ff);
  }
  dfs(1);
  for (int l = (1), _end_ = (int)(17); l <= _end_; ++l)
    for (int i = (1), _end_ = (int)(n); i <= _end_; ++i)
      fa[i][l] = fa[fa[i][l - 1]][l - 1];
  m = read();
  for (int i = (1), _end_ = (int)(m); i <= _end_; ++i) {
    A[i] = read(), B[i] = read();
    int lca = LCA(A[i], B[i]);
    dp[A[i]][0] = min(dp[A[i]][0], dep[lca]);
    dp[B[i]][0] = min(dp[B[i]][0], dep[lca]);
    tr[A[i]].push_back(-B[i]);
    tr[B[i]].push_back(-A[i]);
  }
  DP(1);
  for (int i = (1), _end_ = (int)(n); i <= _end_; ++i)
    dp[i][0] = getans(i, dep[i] - dp[i][0]);
  for (int j = (1), _end_ = (int)(17); j <= _end_; ++j)
    for (int i = (1), _end_ = (int)(n); i <= _end_; ++i)
      dp[i][j] = dp[dp[i][j - 1]][j - 1];
  q = read();
  for (int i = (1), _end_ = (int)(q); i <= _end_; ++i) {
    a[i] = read();
    b[i] = read();
    int lca = LCA(a[i], b[i]);
    if (b[i] == lca) swap(a[i], b[i]);
    if (a[i] == lca) {
      for (int j = 18; j--;)
        if (dep[dp[b[i]][j]] > dep[lca]) b[i] = dp[b[i]][j], c[i] += 1 << j;
      if (dep[dp[b[i]][0]] > dep[lca]) c[i] = -1;
      continue;
    }
    for (int j = 18; j--;)
      if (dep[dp[a[i]][j]] > dep[lca]) a[i] = dp[a[i]][j], c[i] += 1 << j;
    for (int j = 18; j--;)
      if (dep[dp[b[i]][j]] > dep[lca]) b[i] = dp[b[i]][j], c[i] += 1 << j;
    if (dep[dp[a[i]][0]] > dep[lca] || dep[dp[b[i]][0]] > dep[lca])
      c[i] = -1;
    else
      ++c[i], tr[a[i]].push_back(i);
  }
  getdp(1);
  for (int i = (1), _end_ = (int)(q); i <= _end_; ++i) {
    if (c[i] + 1 - bool(s[i]) == 0)
      printf("-1\n");
    else
      printf("%d\n", c[i] + 1 - bool(s[i]));
  }
  return 0;
}