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 _Tp>
inline _Tp read(_Tp& x) {
  char c11 = getchar(), ob = 0;
  x = 0;
  while (c11 ^ '-' && !isdigit(c11)) c11 = getchar();
  if (c11 == '-') c11 = getchar(), ob = 1;
  while (isdigit(c11)) x = x * 10 + c11 - '0', c11 = getchar();
  if (ob) x = -x;
  return x;
}
void file(void) {}
int n, head[200005], cnt, in[200005], out[200005], idx, tree[200005],
    fa[200005][22], dep[200005], h[200005][22], m, q, ans[200005], cc[200005];
vector<pair<int, int> > vec[200005];
void change(int a, int x) {
  for (int i = a; i <= n; i += (i & (-i))) tree[i] += x;
}
int query(int a) {
  int ret = 0;
  for (int i = a; i >= 1; i -= (i & (-i))) ret += tree[i];
  return ret;
}
struct edge {
  int to, next;
} e[400005];
vector<int> to[200005];
void add(int a, int b) {
  e[cnt].to = b;
  e[cnt].next = head[a];
  head[a] = cnt++;
}
void dfs(int u, int pre) {
  dep[u] = dep[pre] + 1;
  fa[u][0] = pre;
  in[u] = ++idx;
  for (int i = 1; i <= 20; ++i) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
  }
  for (int i = head[u]; i; i = e[i].next) {
    if (e[i].to == pre) continue;
    dfs(e[i].to, u);
  }
  out[u] = idx;
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; --i) {
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  }
  if (x == y) return x;
  for (int i = 20; i >= 0; --i) {
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  return fa[x][0];
}
void update(int x, int v) {
  if (dep[h[x][0]] > dep[v]) h[x][0] = v;
}
void calc(int u, int pre) {
  for (int i = head[u]; i; i = e[i].next) {
    if (e[i].to == pre) continue;
    calc(e[i].to, u);
    update(u, h[e[i].to][0]);
  }
}
int gao(int u, int t, int id) {
  for (int i = 20; i >= 0; --i) {
    if (i >= 1 && (h[u][i] == h[u][i - 1])) continue;
    if (dep[h[u][i]] > dep[t]) {
      u = h[u][i];
      ans[id] += (1 << i);
    }
  }
  return u;
}
void getans(int u, int pre) {
  for (int i = 0; i < vec[u].size(); ++i) {
    int t = vec[u][i].first, y = vec[u][i].second;
    cc[y] = query(out[t]) - query(in[t] - 1);
  }
  for (int i = 0; i < to[u].size(); ++i) {
    int t = to[u][i];
    change(in[t], 1);
  }
  for (int i = head[u]; i; i = e[i].next) {
    if (e[i].to == pre) continue;
    getans(e[i].to, u);
  }
  for (int i = 0; i < vec[u].size(); ++i) {
    int t = vec[u][i].first, y = vec[u][i].second;
    if (cc[y] != query(out[t]) - query(in[t] - 1)) ans[y]--;
  }
}
int main() {
  cnt = 1;
  idx = 0;
  read(n);
  for (int i = 2; i <= n; ++i) {
    int x;
    read(x);
    add(x, i);
    add(i, x);
  }
  for (int i = 1; i <= n; ++i) h[i][0] = i;
  dfs(1, 0);
  read(m);
  for (int i = 1; i <= m; ++i) {
    int x, y;
    read(x);
    read(y);
    int xy = lca(x, y);
    update(x, xy);
    update(y, xy);
    to[x].push_back(y);
    to[y].push_back(x);
  }
  calc(1, 0);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 20; ++j) {
      h[i][j] = h[h[i][j - 1]][j - 1];
    }
  }
  read(q);
  for (int i = 1; i <= q; ++i) {
    int x, y;
    read(x);
    read(y);
    if (h[x][20] != h[y][20]) {
      ans[i] = -1;
      continue;
    }
    int xy = lca(x, y);
    x = gao(x, xy, i);
    y = gao(y, xy, i);
    if (x == xy || y == xy)
      ans[i]++;
    else {
      ans[i] += 2;
      vec[x].push_back(make_pair(y, i));
    }
  }
  getans(1, 0);
  for (int i = 1; i <= q; ++i) printf("%d\n", ans[i]);
}