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 nmax = 200005;
struct sweepquery {
  int L, R, wh;
} qq;
int tt[20][nmax], low[20][nmax], l[nmax], r[nmax], rep[nmax], lev[nmax],
    aib[nmax], part[nmax], ans[nmax];
vector<int> v[nmax], oth[nmax];
int n, nr, i, j, m, q, x, y, L, upr;
vector<sweepquery> qr[nmax];
inline int lbit(int x) { return (((x ^ (x - 1)) & x)); }
void update(int poz, int val) {
  for (int idx = poz; idx <= n; idx += lbit(idx)) aib[idx] += val;
}
int compute(int poz) {
  int ret = 0;
  for (int idx = poz; idx > 0; idx -= lbit(idx)) ret += aib[idx];
  return ret;
}
int minlev(int a, int b) {
  if (lev[a] < lev[b]) return a;
  return b;
}
void dfs(int x) {
  rep[++nr] = x;
  l[x] = nr;
  for (int i = 0; i < v[x].size(); i++)
    if (!l[v[x][i]]) {
      lev[v[x][i]] = lev[x] + 1;
      tt[0][v[x][i]] = x;
      dfs(v[x][i]);
    }
  r[x] = nr;
}
void defeseu(int x) {
  for (int i = 0; i < v[x].size(); i++)
    if (l[v[x][i]] > l[x]) {
      defeseu(v[x][i]);
      low[0][x] = minlev(low[0][x], low[0][v[x][i]]);
    }
}
void prc(int tab[][nmax]) {
  for (i = 1; i < 19; i++)
    for (j = 1; j <= n; j++) tab[i][j] = tab[i - 1][tab[i - 1][j]];
}
int cb(int x, int L) {
  upr = x;
  if (x == L) return 0;
  int ret = 0;
  for (int p = 17; p >= 0; p--)
    if (low[p][x] && lev[low[p][x]] > lev[L]) x = low[p][x], ret += (1 << p);
  upr = x;
  if (lev[low[0][x]] > lev[L]) return n + 1;
  return ret + 1;
}
int lca(int a, int b) {
  int pr = 0;
  for (int p = 17; p >= 0; p--) {
    pr = tt[p][a];
    if (pr && (!(l[pr] <= l[b] && l[b] <= r[pr]))) a = pr;
  }
  if (!(l[a] <= l[b] && l[b] <= r[a])) a = tt[0][a];
  return a;
}
void sweep() {
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < oth[i].size(); j++) update(oth[i][j], 1);
    for (int j = 0; j < qr[i].size(); j++) {
      qq = qr[i][j];
      if (qq.wh < 0)
        part[-qq.wh] -= compute(qq.R) - compute(qq.L - 1);
      else
        part[qq.wh] += compute(qq.R) - compute(qq.L - 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (i = 2; i <= n; i++) {
    cin >> x;
    v[x].push_back(i);
    v[i].push_back(x);
  }
  dfs(1);
  lev[0] = (1 << 30);
  prc(tt);
  cin >> m;
  for (i = 1; i <= n; i++) low[0][i] = i;
  for (i = 1; i <= m; i++) {
    cin >> x >> y;
    L = lca(x, y);
    low[0][x] = minlev(low[0][x], L);
    low[0][y] = minlev(low[0][y], L);
    oth[l[x]].push_back(l[y]);
    oth[l[y]].push_back(l[x]);
  }
  defeseu(1);
  prc(low);
  cin >> q;
  for (i = 1; i <= q; i++) {
    cin >> x >> y;
    L = lca(x, y);
    ans[i] = cb(x, L);
    x = upr;
    ans[i] += cb(y, L);
    y = upr;
    if (x != L && y != L) {
      qr[l[x] - 1].push_back({l[y], r[y], -i});
      qr[r[x]].push_back({l[y], r[y], i});
    }
  }
  sweep();
  for (i = 1; i <= q; i++) {
    if (ans[i] > n) {
      cout << "-1\n";
      continue;
    }
    ans[i] -= (part[i] != 0);
    cout << ans[i] << '\n';
  }
  return 0;
}