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;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);
const int MAXN = 2e5 + 5;
const int MAXM = 2e6 + 5;
const int MOD = 1e9 + 7;
int sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
long long pw(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return ret;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void inc(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void dec(long long &a, long long b) {
  a -= b;
  if (a < 0) a += MOD;
}
int mul(int a, int b) {
  long long c = 1ll * a * b;
  return c - c / MOD * MOD;
}
int n, m, q;
vector<int> G[MAXN];
int tim, L[MAXN], R[MAXN], dep[MAXN], p[MAXN][20];
void dfs(int u) {
  L[u] = ++tim;
  for (int i = 1; i < 20; i++) {
    if ((1 << i) > dep[u])
      break;
    else
      p[u][i] = p[p[u][i - 1]][i - 1];
  }
  for (auto v : G[u]) {
    p[v][0] = u;
    dep[v] = dep[u] + 1;
    dfs(v);
  }
  R[u] = tim;
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int h = dep[u] - dep[v];
  for (int i = 0; i < 20; i++)
    if ((1 << i) & h) u = p[u][i];
  if (u == v) return u;
  for (int i = 20 - 1; i >= 0; i--)
    if (p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
  return u == v ? u : p[u][0];
}
int ans[MAXN], go[MAXN][20];
void dfs2(int u) {
  for (auto v : G[u]) {
    dfs2(v);
    if (!go[v][0]) continue;
    if (!go[u][0] || dep[go[u][0]] > dep[go[v][0]]) go[u][0] = go[v][0];
  }
}
void init() {
  for (int i = 1; i < n + 1; i++)
    if (go[i][0] == i) go[i][0] = 0;
  for (int j = 1; j < 20; j++)
    for (int i = 1; i < n + 1; i++) go[i][j] = go[go[i][j - 1]][j - 1];
}
struct Q {
  int v, id, tmp;
};
vector<Q> qr[MAXN];
int c[MAXN];
vector<int> way[MAXN];
void upd(int x) {
  for (; x <= n; x += x & -x) c[x]++;
}
int qry(int x) {
  int ret = 0;
  for (; x; x -= x & -x) ret += c[x];
  return ret;
}
void dfs3(int u) {
  int sz = ((int)(qr[u]).size());
  for (int i = 0; i < sz; i++) {
    int v = qr[u][i].v;
    qr[u][i].tmp = qry(R[v]) - qry(L[v] - 1);
  }
  for (auto v : way[u]) upd(L[v]);
  for (auto v : G[u]) dfs3(v);
  for (int i = 0; i < sz; i++) {
    int v = qr[u][i].v;
    if (qr[u][i].tmp != qry(R[v]) - qry(L[v] - 1)) ans[qr[u][i].id]--;
  }
}
int main() {
  scanf("%d", &n);
  int p;
  for (int i = 2; i < n + 1; i++) {
    scanf("%d", &p);
    G[p].push_back(i);
  }
  tim = 0;
  dep[1] = 0;
  dfs(1);
  int u, v, anc;
  scanf("%d", &m);
  for (int i = 1; i < m + 1; i++) {
    scanf("%d%d", &u, &v);
    if (dep[u] > dep[v]) swap(u, v);
    anc = lca(u, v);
    if (anc == u) {
      if (!go[v][0] || dep[go[v][0]] > dep[u]) go[v][0] = u;
    } else {
      if (!go[u][0] || dep[go[u][0]] > dep[anc]) go[u][0] = anc;
      if (!go[v][0] || dep[go[v][0]] > dep[anc]) go[v][0] = anc;
      way[u].push_back(v);
      way[v].push_back(u);
    }
  }
  dfs2(1);
  init();
  scanf("%d", &q);
  for (int i = 1; i < q + 1; i++) {
    scanf("%d%d", &u, &v);
    if (dep[u] > dep[v]) swap(u, v);
    anc = lca(u, v);
    if (u == anc) {
      for (int j = 20 - 1; j >= 0; j--)
        if (go[v][j] && dep[go[v][j]] > dep[u])
          v = go[v][j], ans[i] += (1 << j);
      if (go[v][0])
        ans[i]++;
      else
        ans[i] = -1;
    } else {
      for (int j = 20 - 1; j >= 0; j--)
        if (go[u][j] && dep[go[u][j]] > dep[anc])
          u = go[u][j], ans[i] += (1 << j);
      for (int j = 20 - 1; j >= 0; j--)
        if (go[v][j] && dep[go[v][j]] > dep[anc])
          v = go[v][j], ans[i] += (1 << j);
      if (go[u][0] && go[v][0]) {
        ans[i] += 2;
        qr[u].push_back(Q{v, i, 0});
      } else
        ans[i] = -1;
    }
  }
  dfs3(1);
  for (int i = 1; i < q + 1; i++) printf("%d\n", ans[i]);
}