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 LogN = 18, N = 2e5 + 10, Q = 2e5 + 10;
int n, m, q, par[LogN][N], bus[LogN][N], dep[N], lft[N], rgt[N], ft[2 * N],
    ans[Q];
vector<int> child[N], dest[N];
vector<pair<int, int>> query[N];
int t = 0;
void dfs_order(int u) {
  lft[u] = t++;
  for (int v : child[u]) {
    dfs_order(v);
    if (dep[bus[0][v]] < dep[bus[0][u]]) {
      bus[0][u] = bus[0][v];
    }
  }
  rgt[u] = t;
}
int lca(int u, int v) {
  if (dep[u] > dep[v]) {
    swap(u, v);
  }
  for (int k = LogN - 1; k >= 0; k--) {
    if (dep[v] - dep[u] >> k & 1) {
      v = par[k][v];
    }
  }
  if (u == v) {
    return u;
  }
  for (int k = LogN - 1; k >= 0; k--) {
    if (par[k][u] != par[k][v]) {
      u = par[k][u];
      v = par[k][v];
    }
  }
  return par[0][u];
}
int bus_stops(int u, int anc) {
  if (u == anc) {
    return 0;
  }
  int s = 0;
  for (int k = LogN - 1; k >= 0; k--) {
    if (dep[bus[k][u]] > dep[anc]) {
      u = bus[k][u];
      s += 1 << k;
    }
  }
  return dep[bus[0][u]] <= dep[anc] ? s + 1 : -1;
}
int ride(int u, int rgt) {
  for (int k = LogN - 1; k >= 0; k--) {
    if (rgt >> k & 1) {
      u = bus[k][u];
    }
  }
  return u;
}
void inc(int i) {
  for (i++; i <= t; i += i & -i) {
    ft[i]++;
  }
}
int qry(int i) {
  int s = 0;
  for (i++; i; i -= i & -i) {
    s += ft[i];
  }
  return s;
}
void dfs_match(int u) {
  queue<int> count;
  for (pair<int, int> q : query[u]) {
    int v = q.first, x = qry(rgt[v] - 1) - qry(lft[v] - 1);
    count.push(x);
  }
  for (int v : dest[u]) {
    inc(lft[v]);
  }
  for (int v : child[u]) {
    dfs_match(v);
  }
  for (pair<int, int> q : query[u]) {
    int v = q.first, i = q.second, x = qry(rgt[v] - 1) - qry(lft[v] - 1);
    assert(x >= count.front());
    if (x > count.front()) {
      ans[i]--;
    }
    count.pop();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int u = 1, v; u < n; u++) {
    cin >> par[0][u];
    par[0][u]--;
    child[par[0][u]].push_back(u);
    dep[u] = dep[par[0][u]] + 1;
  }
  for (int k = 1; k < LogN; k++) {
    for (int u = 1; u < n; u++) {
      par[k][u] = par[k - 1][par[k - 1][u]];
    }
  }
  cin >> m;
  for (int u = 0; u < n; u++) {
    bus[0][u] = u;
  }
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    a--;
    b--;
    dest[a].push_back(b);
    dest[b].push_back(a);
    int c = lca(a, b);
    if (dep[c] < dep[bus[0][a]]) {
      bus[0][a] = c;
    }
    if (dep[c] < dep[bus[0][b]]) {
      bus[0][b] = c;
    }
  }
  dfs_order(0);
  for (int k = 1; k < LogN; k++) {
    for (int u = 0; u < n; u++) {
      bus[k][u] = bus[k - 1][bus[k - 1][u]];
    }
  }
  cin >> q;
  for (int i = 0, v, u; i < q; i++) {
    cin >> v >> u;
    v--;
    u--;
    if (dep[u] > dep[v]) {
      swap(u, v);
    }
    int w = lca(u, v);
    if (u == w) {
      ans[i] = bus_stops(v, u);
    } else {
      int a = bus_stops(u, w), b = bus_stops(v, w);
      if (a == -1 || b == -1) {
        ans[i] = -1;
      } else {
        ans[i] = a + b;
        int x = ride(u, a - 1), y = ride(v, b - 1);
        if (lft[x] > lft[y]) {
          swap(x, y);
        }
        query[x].emplace_back(y, i);
      }
    }
  }
  dfs_match(0);
  for (int i = 0; i < q; i++) {
    cout << ans[i] << endl;
  }
}