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 N = 2e5 + 5;
const int K = 400;
const int LOG = 20;
int n, m, q, tick;
int st[N], nd[N], dep[N], lca[LOG][N];
vector<int> v[N], p[N];
vector<pair<int, int> > qq[N];
int ans[N];
int get(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = LOG - 1; i >= 0; i--)
    if (dep[x] - (1 << i) >= dep[y]) x = lca[i][x];
  if (x == y) return x;
  for (int i = LOG - 1; i >= 0; i--)
    if (lca[i][x] != lca[i][y]) x = lca[i][x], y = lca[i][y];
  return lca[0][x];
}
void dfs(int p, int x) {
  lca[0][x] = p;
  for (int i = 1; i < LOG; i++) lca[i][x] = lca[i - 1][lca[i - 1][x]];
  dep[x] = dep[p] + 1;
  st[x] = ++tick;
  for (auto u : v[x]) {
    if (u != p) {
      dfs(x, u);
    }
  }
  nd[x] = tick;
}
int go[N];
int best(int x, int y) {
  if (dep[x] < dep[y]) return x;
  return y;
}
int inside(int x, int y) { return st[y] <= st[x] and nd[x] <= nd[y]; }
int upNode[N], upCost[N];
void dfs2(int pr, int x) {
  go[x] = x;
  for (auto u : p[x]) go[x] = best(go[x], u);
  for (auto u : v[x]) {
    if (u != pr) {
      dfs2(x, u);
      go[x] = best(go[x], go[u]);
    }
  }
  int y = go[x];
  int needDist = min(K, dep[x]);
  int cnt = y != x;
  while (dep[x] - dep[y] < needDist and y != go[y]) {
    cnt++;
    y = go[y];
  }
  if (dep[x] - dep[y] >= needDist) {
    upNode[x] = y;
    upCost[x] = cnt;
  }
}
set<int> s[N];
void dfs3(int pr, int x) {
  for (auto u : v[x]) {
    if (u != pr) {
      dfs3(x, u);
      if (s[x].size() < s[u].size()) swap(s[x], s[u]);
      for (auto v : s[u]) s[x].insert(v);
    }
  }
  for (auto tmp : qq[x]) {
    int y = tmp.first;
    int i = tmp.second;
    auto it = s[x].lower_bound(st[y]);
    if (it != s[x].end() and *it <= nd[y]) ans[i]--;
  }
}
int main() {
  scanf("%d", &n);
  for (int x = 2; x <= n; x++) {
    int y;
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int c = get(x, y);
    p[x].push_back(c);
    p[y].push_back(c);
    s[x].insert(st[y]);
    s[y].insert(st[x]);
  }
  dfs2(0, 1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int c = get(x, y);
    int res = 0;
    auto climb = [&](int &x) {
      while (dep[x] - dep[c] > K and !inside(c, go[x])) {
        if (!upNode[x]) {
          res = -1;
          break;
        }
        res += upCost[x];
        x = upNode[x];
      }
      while (!inside(c, go[x])) {
        if (go[x] == x) {
          res = -1;
          break;
        }
        res++;
        x = go[x];
      }
    };
    climb(x);
    if (res == -1) {
      ans[i] = -1;
      continue;
    }
    climb(y);
    if (res == -1) {
      ans[i] = -1;
      continue;
    }
    if (inside(x, y) or inside(y, x)) {
      ans[i] = res + 1;
    } else {
      ans[i] = res + 2;
      qq[x].push_back({y, i});
    }
  }
  dfs3(0, 1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}