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 + 7;
const int logn = 19;
vector<int> adj[maxn];
int idcnt, l[maxn], r[maxn], dep[maxn], anc[maxn][logn];
void dfs1(int u, int up) {
  l[u] = ++idcnt;
  dep[u] = dep[up] + 1;
  anc[u][0] = up;
  for (int i = 1; i < logn; i++) {
    if (dep[u] <= (1 << i)) break;
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == up) continue;
    dfs1(v, u);
  }
  r[u] = idcnt;
}
int qlca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = logn - 1; i >= 0; i--)
    if (dep[v] > (1 << i) && dep[anc[v][i]] >= dep[u]) v = anc[v][i];
  if (u == v) return u;
  for (int i = logn - 1; i >= 0; i--)
    if (dep[u] > (1 << i) && anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  return anc[u][0];
}
vector<int> bus[maxn];
int nex[maxn][logn];
void dfs2(int u, int up) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == up) continue;
    dfs2(v, u);
    if (dep[nex[v][0]] < dep[nex[u][0]]) nex[u][0] = nex[v][0];
  }
}
int n, st[maxn];
int lowbit(int x) { return x & (-x); }
void add(int i, int x) {
  for (; i <= n; i += lowbit(i)) st[i] += x;
}
int qsum(int i) {
  int res = 0;
  for (; i > 0; i -= lowbit(i)) res += st[i];
  return res;
}
struct node {
  int id, v;
  node(int id = 0, int v = 0) : id(id), v(v) {}
};
vector<node> qr[maxn];
int ans[maxn], cmp[maxn];
void dfs3(int u, int up) {
  for (int i = 0; i < qr[u].size(); i++) {
    node cur = qr[u][i];
    int id = cur.id, v = cur.v;
    cmp[id] = qsum(r[v]) - qsum(l[v] - 1);
  }
  for (int i = 0; i < bus[u].size(); i++) {
    int v = bus[u][i];
    add(l[v], -1);
  }
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == up) continue;
    dfs3(v, u);
  }
  for (int i = 0; i < qr[u].size(); i++) {
    node cur = qr[u][i];
    int id = cur.id, v = cur.v;
    if (qsum(r[v]) - qsum(l[v] - 1) != cmp[id]) ans[id]--;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int v;
    scanf("%d", &v);
    adj[i].push_back(v);
    adj[v].push_back(i);
  }
  dfs1(1, 1);
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) nex[i][0] = i;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    bus[a].push_back(b);
    bus[b].push_back(a);
    int lca = qlca(a, b);
    if (dep[lca] < dep[nex[a][0]]) nex[a][0] = lca;
    if (dep[lca] < dep[nex[b][0]]) nex[b][0] = lca;
  }
  dfs2(1, 1);
  for (int i = 1; i < logn; i++)
    for (int j = 1; j <= n; j++) nex[j][i] = nex[nex[j][i - 1]][i - 1];
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u > v) swap(u, v);
    int lca = qlca(u, v);
    for (int j = logn - 1; j >= 0; j--)
      if (dep[nex[v][j]] > dep[lca]) {
        v = nex[v][j];
        ans[i] += (1 << j);
      }
    if (u == lca) {
      if (dep[nex[v][0]] > dep[lca]) {
        ans[i] = -1;
        continue;
      }
      if (dep[v] > dep[lca]) ans[i]++;
    } else {
      for (int j = logn - 1; j >= 0; j--)
        if (dep[nex[u][j]] > dep[lca]) {
          u = nex[u][j];
          ans[i] += (1 << j);
        }
      if (dep[nex[u][0]] > dep[lca] || dep[nex[v][0]] > dep[lca]) {
        ans[i] = -1;
        continue;
      }
      ans[i] += 2;
      if (u > v) swap(u, v);
      qr[v].push_back(node(i, u));
    }
  }
  dfs3(1, 1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}