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 IN() {
  int c, f, x;
  while (!isdigit(c = getchar()) && c != '-')
    ;
  c == '-' ? (f = 1, x = 0) : (f = 0, x = c - '0');
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c - '0';
  return !f ? x : -x;
}
const int N = 2e5 + 19;
struct Point {
  int x, y;
  bool operator<(const Point &B) const { return x < B.x; }
} P[N * 2];
struct QType {
  int x, f, l, r, id;
  bool operator<(const QType &B) const { return x < B.x; }
} Q[N * 2];
struct Edge {
  int y, nxt;
} E[N];
int las[N], dep[N], I[N], O[N], fa[20][N], go[20][N];
int a[N], b[N], bao[N], val[N], ans[N];
int n, m, q, u, v, cnt, tot, qc, pc;
int Qxl, Qxr, Qyl, Qyr, res;
int sum[N];
void Add(int x, int v) {
  for (; x <= n; x += x & -x) sum[x] += v;
}
int Qry(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += sum[x];
  return res;
}
void Add_Edge(int x, int y) {
  E[cnt] = (Edge){y, las[x]};
  las[x] = cnt++;
}
void dfs(int x) {
  I[x] = ++tot;
  for (int i = las[x], y; ~i; i = E[i].nxt) {
    y = E[i].y;
    fa[0][y] = x;
    dep[y] = dep[x] + 1;
    dfs(y);
  }
  O[x] = tot;
}
int LCA(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = 0, k = dep[y] - dep[x]; k; k >>= 1, i++)
    if (k & 1) y = fa[i][y];
  if (x == y) return x;
  for (int i = 19; ~i; i--)
    if (fa[i][x] != fa[i][y]) x = fa[i][x], y = fa[i][y];
  return fa[0][x];
}
void jump(int &y, int x, int &ans) {
  for (int i = 19; ~i; i--) {
    if (dep[go[i][y]] > dep[x]) ans += 1 << i, y = go[i][y];
  }
}
int work(int id, int x, int y) {
  if (x == y) return 0;
  if (dep[x] > dep[y]) swap(x, y);
  if (I[x] <= I[y] && I[y] <= O[x]) {
    if (dep[go[19][y]] > dep[x]) return -1;
    int ans = 0;
    jump(y, x, ans);
    return ans + 1;
  }
  int z = LCA(x, y);
  if (dep[go[19][x]] > dep[z] || dep[go[19][y]] > dep[z]) return -1;
  int ans = 0;
  jump(x, z, ans);
  jump(y, z, ans);
  Q[++qc] = (QType){I[x] - 1, -1, I[y], O[y], id};
  Q[++qc] = (QType){O[x], 1, I[y], O[y], id};
  bao[id] = 1;
  return ans;
}
int main() {
  memset(las, -1, sizeof(las));
  n = IN();
  for (int i = 2; i < n + 1; i++) Add_Edge(IN(), i);
  dep[1] = 1;
  dfs(1);
  for (int i = 1; i < 20; i++) {
    for (int x = 1; x < n + 1; x++) fa[i][x] = fa[i - 1][fa[i - 1][x]];
  }
  for (int i = 1; i < n + 1; i++) go[0][i] = i;
  m = IN();
  for (int i = 1; i < m + 1; i++) {
    a[i] = IN(), b[i] = IN();
    P[++pc] = (Point){I[a[i]], I[b[i]]};
    P[++pc] = (Point){I[b[i]], I[a[i]]};
    int c = LCA(a[i], b[i]);
    if (dep[c] < dep[go[0][a[i]]]) go[0][a[i]] = c;
    if (dep[c] < dep[go[0][b[i]]]) go[0][b[i]] = c;
  }
  for (int i = n; i > 1; i--) {
    if (dep[go[0][i]] < dep[go[0][fa[0][i]]]) {
      go[0][fa[0][i]] = go[0][i];
    }
  }
  for (int i = 1; i < 20; i++) {
    for (int x = 1; x < n + 1; x++) go[i][x] = go[i - 1][go[i - 1][x]];
  }
  q = IN();
  for (int i = 1; i < q + 1; i++) {
    u = IN(), v = IN();
    ans[i] = work(i, u, v);
  }
  sort(Q + 1, Q + qc + 1);
  sort(P + 1, P + pc + 1);
  int c = 1;
  for (int i = 1; i < qc + 1; i++) {
    for (; c <= pc && P[c].x <= Q[i].x; c++) {
      Add(P[c].y, 1);
    }
    val[Q[i].id] += Q[i].f * (Qry(Q[i].r) - Qry(Q[i].l - 1));
  }
  for (int i = 1; i < q + 1; i++)
    if (bao[i]) {
      ans[i] += (val[i] > 0 ? 1 : 2);
    }
  for (int i = 1; i < q + 1; i++) printf("%d\n", ans[i]);
}