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 n, m, q;
int strt[((int)201 * 1000)], fnsh[((int)201 * 1000)], _cnt;
int dis[((int)201 * 1000)], par[((int)19)][((int)201 * 1000)],
    dad[((int)19)][((int)201 * 1000)];
vector<int> e[((int)201 * 1000)], vec[((int)201 * 1000)],
    seg[4 * ((int)201 * 1000)];
void pre_dfs(int x) {
  strt[x] = _cnt++;
  for (int i = 1; i < ((int)19); i++) par[i][x] = par[i - 1][par[i - 1][x]];
  for (auto u : e[x]) par[0][u] = x, dis[u] = dis[x] + 1, pre_dfs(u);
  fnsh[x] = _cnt;
}
int iPar(int x, int num) {
  for (int i = 0; i < ((int)19); i++)
    if ((num & (1 << i))) x = par[i][x];
  return x;
}
int lca(int x, int y) {
  if (dis[x] < dis[y]) swap(x, y);
  x = iPar(x, dis[x] - dis[y]);
  if (x == y) return x;
  for (int i = ((int)19) - 1; i >= 0; i--)
    if (par[i][x] != par[i][y]) x = par[i][x], y = par[i][y];
  return par[0][x];
}
void dfs(int x) {
  dad[0][x] = x;
  for (auto u : vec[x])
    if (dis[u] < dis[dad[0][x]]) dad[0][x] = u;
  for (auto u : e[x]) {
    dfs(u);
    if (dis[dad[0][u]] < dis[dad[0][x]]) dad[0][x] = dad[0][u];
  }
}
void update2(int q, int val, int xl = 0, int xr = ((int)201 * 1000),
             int id = 1) {
  seg[id].push_back(val);
  if (xl == xr - 1) return;
  int mid = (xl + xr) / 2;
  if (q < mid)
    update2(q, val, xl, mid, id * 2);
  else
    update2(q, val, mid, xr, id * 2 + 1);
}
void build(int xl = 0, int xr = ((int)201 * 1000), int id = 1) {
  sort(seg[id].begin(), seg[id].end());
  if (xl == xr - 1) return;
  int mid = (xl + xr) / 2;
  build(xl, mid, id * 2);
  build(mid, xr, id * 2 + 1);
}
bool query2(int ql, int qr, int st, int fn, int xl = 0,
            int xr = ((int)201 * 1000), int id = 1) {
  if (qr <= xl || xr <= ql) return 0;
  if (ql <= xl && xr <= qr) {
    int it = lower_bound(seg[id].begin(), seg[id].end(), st) - seg[id].begin();
    if (it != (int)seg[id].size() && seg[id][it] < fn) return 1;
    return 0;
  }
  int mid = (xl + xr) / 2;
  return query2(ql, qr, st, fn, xl, mid, id * 2) |
         query2(ql, qr, st, fn, mid, xr, id * 2 + 1);
}
pair<int, int> query(int x, int y) {
  int res = 0;
  for (int i = ((int)19) - 1; i >= 0; i--)
    if (dis[dad[i][x]] > dis[y]) res += (1 << i), x = dad[i][x];
  return {x, res};
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int p;
    scanf("%d", &p);
    e[p].push_back(i);
  }
  pre_dfs(1);
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int v, u, p;
    scanf("%d%d", &v, &u);
    p = lca(v, u);
    vec[v].push_back(p);
    vec[u].push_back(p);
    update2(strt[v], strt[u]);
    update2(strt[u], strt[v]);
  }
  build();
  dfs(1);
  for (int i = 1; i < ((int)19); i++)
    for (int j = 1; j <= n; j++) dad[i][j] = dad[i - 1][dad[i - 1][j]];
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    int v, u, ans;
    scanf("%d%d", &v, &u);
    int p = lca(v, u);
    if (dis[v] < dis[u]) swap(v, u);
    if (p == u)
      ans = query(v, u).second + 1;
    else {
      pair<int, int> ex = query(v, p), ex2 = query(u, p);
      ans = ex.second + ex2.second + 2;
      if (query2(strt[ex.first], fnsh[ex.first], strt[ex2.first],
                 fnsh[ex2.first]))
        ans--;
    }
    if (ans > ((int)201 * 1000)) ans = -1;
    printf("%d\n", ans);
  }
  return 0;
}