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>
const int N = 200005;
int n, m, q, cnt, last[N], dfn[N], mx[N], tim, up[N][20], fa[N][20], dep[N],
    ans[N], tmp[N], c[N];
std::vector<int> vec[N];
std::vector<std::pair<int, int> > que[N];
struct edge {
  int to, next;
} e[N];
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void addedge(int u, int v) {
  e[++cnt].to = v;
  e[cnt].next = last[u];
  last[u] = cnt;
}
void dfs(int x) {
  dep[x] = dep[fa[x][0]] + 1;
  dfn[x] = ++tim;
  up[x][0] = x;
  for (int i = 1; i <= 18; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = last[x]; i; i = e[i].next) dfs(e[i].to);
  mx[x] = tim;
}
int get_lca(int x, int y) {
  if (dep[x] < dep[y]) std::swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void build() {
  for (int i = n; i >= 1; i--) {
    up[i][0] = i;
    for (int j = last[i]; j; j = e[j].next)
      up[i][0] =
          dep[up[e[j].to][0]] < dep[up[i][0]] ? up[e[j].to][0] : up[i][0];
    for (int j = 0; j < vec[i].size(); j++) {
      int lca = get_lca(i, vec[i][j]);
      up[i][0] = dep[lca] < dep[up[i][0]] ? lca : up[i][0];
    }
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 18; j++) up[i][j] = up[up[i][j - 1]][j - 1];
}
void ins(int x, int y) {
  while (x <= n) c[x] += y, x += x & (-x);
}
int query(int x) {
  int ans = 0;
  while (x) ans += c[x], x -= x & (-x);
  return ans;
}
void solve(int x) {
  for (int i = 0; i < que[x].size(); i++)
    tmp[que[x][i].second] =
        query(mx[que[x][i].first]) - query(dfn[que[x][i].first] - 1);
  for (int i = 0; i < vec[x].size(); i++) ins(dfn[vec[x][i]], 1);
  for (int i = last[x]; i; i = e[i].next) solve(e[i].to);
  for (int i = 0; i < que[x].size(); i++)
    ans[que[x][i].second] +=
        (tmp[que[x][i].second] ==
         query(mx[que[x][i].first]) - query(dfn[que[x][i].first] - 1));
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) fa[i][0] = read(), addedge(fa[i][0], i);
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  dfs(1);
  build();
  q = read();
  for (int i = 1; i <= q; i++) {
    int x = read(), y = read(), lca = get_lca(x, y);
    for (int j = 18; j >= 0; j--) {
      if (dep[up[x][j]] > dep[lca]) x = up[x][j], ans[i] += 1 << j;
      if (dep[up[y][j]] > dep[lca]) y = up[y][j], ans[i] += 1 << j;
    }
    if (dep[up[x][0]] > dep[lca] || dep[up[y][0]] > dep[lca]) {
      ans[i] = -1;
      continue;
    }
    ans[i]++;
    if (x != lca && y != lca) que[x].push_back(std::make_pair(y, i));
  }
  solve(1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}