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 maxn = 2e5 + 1000;
vector<int> side[maxn];
int size[maxn], dep[maxn], f[maxn][20], g[maxn][20];
int dfn[maxn], dfn_cnt;
int up[maxn];
void dfs1(int u, int fa) {
  dep[u] = dep[fa] + 1;
  f[u][0] = fa;
  dfn[u] = ++dfn_cnt;
  size[u] = 1;
  for (int i = 0; i < side[u].size(); i++) {
    int v = side[u][i];
    if (v == fa) continue;
    dfs1(v, u);
    size[u] += size[v];
  }
}
void dfs2(int u, int fa) {
  for (int i = 0; i < side[u].size(); i++) {
    int v = side[u][i];
    if (v == fa) continue;
    dfs2(v, u);
    if (dep[up[v]] < dep[up[u]]) up[u] = up[v];
  }
  g[u][0] = up[u];
}
int n;
void init1() {
  for (int i = (1), iend = (19); i <= iend; i++)
    for (int j = (1), jend = (n); j <= jend; j++)
      f[j][i] = f[f[j][i - 1]][i - 1];
}
void init2() {
  for (int i = (1), iend = (19); i <= iend; i++)
    for (int j = (1), jend = (n); j <= jend; j++)
      g[j][i] = g[g[j][i - 1]][i - 1];
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int i = 19; i >= 0; i--)
    if (dep[f[u][i]] >= dep[v]) u = f[u][i];
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (f[u][i] != f[v][i]) u = f[u][i], v = f[v][i];
  return f[u][0];
}
int ans[maxn], tmp[maxn];
struct Query {
  int idx, l, r, x, ty;
};
vector<Query> Q;
bool cmp(Query a, Query b) { return a.x < b.x; }
vector<int> po[maxn];
struct BIT {
  int c[maxn];
  void add(int u, int val) {
    for (int i = u; i < maxn; i += i & -i) c[i] += val;
  }
  int query(int u) {
    int ans = 0;
    for (int i = u; i; i -= i & -i) ans += c[i];
    return ans;
  }
  int seg(int l, int r) { return query(r) - query(l - 1); }
} t;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = (2), iend = (n); i <= iend; i++) {
    int v;
    cin >> v;
    side[i].push_back(v);
    side[v].push_back(i);
  }
  dfs1(1, 0);
  init1();
  for (int i = (1), iend = (n); i <= iend; i++) up[i] = i;
  int m;
  cin >> m;
  for (int i = (1), iend = (m); i <= iend; i++) {
    int a, b;
    cin >> a >> b;
    int l = lca(a, b);
    po[dfn[a]].push_back(dfn[b]);
    po[dfn[b]].push_back(dfn[a]);
    if (dep[l] < dep[up[a]]) up[a] = l;
    if (dep[l] < dep[up[b]]) up[b] = l;
  }
  dfs2(1, 0);
  init2();
  int q;
  cin >> q;
  for (int i = (1), iend = (q); i <= iend; i++) {
    int u, v;
    cin >> u >> v;
    int l = lca(u, v);
    for (int j = 19; j >= 0; j--)
      if (g[u][j] && g[u][j] != u && dep[g[u][j]] > dep[l])
        u = g[u][j], ans[i] += 1 << j;
    for (int j = 19; j >= 0; j--)
      if (g[v][j] && g[v][j] != v && dep[g[v][j]] > dep[l])
        v = g[v][j], ans[i] += 1 << j;
    if ((l == v && g[u][0] != u) || (l == u && g[v][0] != v))
      ans[i]++;
    else if (g[u][0] == u || g[v][0] == v)
      ans[i] = -1;
    else {
      if (dfn[u] - 1 >= 1)
        Q.push_back((Query){i, dfn[v], dfn[v] + size[v] - 1, dfn[u] - 1, -1});
      Q.push_back(
          (Query){i, dfn[v], dfn[v] + size[v] - 1, dfn[u] + size[u] - 1, 1});
      ans[i] += 2;
    }
  }
  sort(Q.begin(), Q.end(), cmp);
  int now = 0;
  for (int i = (1), iend = (n); i <= iend; i++) {
    for (int j = 0; j < po[i].size(); j++) t.add(po[i][j], 1);
    while (now < Q.size() && Q[now].x == i) {
      tmp[Q[now].idx] += Q[now].ty * t.seg(Q[now].l, Q[now].r);
      now++;
    }
  }
  for (int i = (1), iend = (q); i <= iend; i++)
    if (ans[i] != -1 && tmp[i]) ans[i]--;
  for (int i = (1), iend = (q); i <= iend; i++) cout << ans[i] << endl;
  return 0;
}