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>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 200010, LOG = 19;
int n, m, q, u, v, x, y, t, a, b;
int par[MAXN][LOG];
int h[MAXN];
int up[MAXN][LOG];
int stt[MAXN], fnt[MAXN], timer = 1;
int ans[MAXN];
int B[MAXN];
set<pair<int, int> > fen[MAXN];
vector<int> G[MAXN], V[MAXN];
vector<pair<int, int> > Q[MAXN];
int Lca(int x, int y) {
  if (h[x] > h[y]) swap(x, y);
  for (int i = 0; i < LOG; i++)
    if ((h[y] - h[x]) & (1 << i)) y = par[y][i];
  if (x == y) return x;
  for (int i = LOG - 1; i >= 0; i--)
    if (par[x][i] != par[y][i]) {
      x = par[x][i];
      y = par[y][i];
    }
  return par[x][0];
}
void dfs1(int node) {
  stt[node] = timer++;
  for (int v : G[node]) dfs1(v);
  fnt[node] = timer;
}
inline bool is_par(int u, int v) {
  return stt[u] <= stt[v] && fnt[v] <= fnt[u];
}
inline void add(int pos, pair<int, int> p) {
  for (; pos < MAXN; pos += pos & -pos) fen[pos].insert(p);
}
inline void rem(int pos, pair<int, int> p) {
  for (; pos < MAXN; pos += pos & -pos) fen[pos].erase(p);
}
inline pair<int, int> get(int pos) {
  pair<int, int> res = {0, 0};
  for (; pos; pos -= pos & -pos)
    if (fen[pos].size()) res = max(res, *fen[pos].rbegin());
  return res;
}
void dfs2(int node) {
  for (pair<int, int> p : Q[node]) add(stt[p.first], {fnt[p.first], p.second});
  for (int v : V[node]) {
    int l = stt[v], r = fnt[v];
    while (1) {
      pair<int, int> p = get(l);
      if (p.first < r) break;
      int i = p.second;
      ans[i]--;
      rem(stt[B[i]], {fnt[B[i]], i});
    }
  }
  for (int v : G[node]) dfs2(v);
  for (pair<int, int> p : Q[node]) rem(stt[p.first], {fnt[p.first], p.second});
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> par[i][0];
    G[par[i][0]].push_back(i);
    h[i] = h[par[i][0]] + 1;
    for (int j = 1; j < LOG; j++) par[i][j] = par[par[i][j - 1]][j - 1];
  }
  for (int i = 1; i <= n; i++) up[i][0] = i;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    int lca = Lca(a, b);
    up[a][0] = min(up[a][0], lca);
    up[b][0] = min(up[b][0], lca);
    V[a].push_back(b);
    V[b].push_back(a);
  }
  for (int i = n; i; i--)
    if (up[i][0] != i) up[par[i][0]][0] = min(up[par[i][0]][0], up[i][0]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < LOG; j++) up[i][j] = up[up[i][j - 1]][j - 1];
  dfs1(1);
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> a >> b;
    if (up[a][LOG - 1] != up[b][LOG - 1])
      ans[i] = -1;
    else {
      int lca = Lca(a, b);
      ans[i] += (a != lca) + (b != lca);
      for (int j = LOG - 1; j >= 0; j--)
        if (!is_par(up[a][j], lca)) a = up[a][j], ans[i] += (1 << j);
      for (int j = LOG - 1; j >= 0; j--)
        if (!is_par(up[b][j], lca)) b = up[b][j], ans[i] += (1 << j);
      if (min(a, b) != lca) Q[a].push_back({b, i});
      B[i] = b;
    }
  }
  dfs2(1);
  for (int i = 1; i <= q; i++) cout << ans[i] << '\n';
  return 0;
}