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 MX = 200005, LMX = 19;
struct PST {
  PST *izq, *der;
  int x;
  PST() : izq(0), der(0), x(0) {}
  PST(int x) : izq(0), der(0), x(x) {}
  PST(PST *_izq, PST *_der) {
    izq = _izq, der = _der;
    x = izq->x + der->x;
  }
  void build(int i, int j) {
    if (i == j) return;
    int m = (i + j) / 2;
    (izq = new PST)->build(i, m);
    (der = new PST)->build(m + 1, j);
  }
  PST *update(int i, int j, int p) {
    if (p < i || j < p) return this;
    if (i == j) return new PST(x + 1);
    int m = (i + j) / 2;
    return new PST(izq->update(i, m, p), der->update(m + 1, j, p));
  }
  int query(int i, int j, int a, int b) {
    if (b < i || j < a) return 0;
    if (a <= i && j <= b) return x;
    int m = (i + j) / 2;
    return izq->query(i, m, a, b) + der->query(m + 1, j, a, b);
  }
};
int n, p[MX][LMX], an[MX][LMX], m, a, b, q, lvl[MX];
int cn = 0, ini[MX], fin[MX];
vector<int> adj[MX], pos[MX];
PST *st[MX];
int LCA(int a, int b) {
  if (lvl[a] < lvl[b]) swap(a, b);
  for (int j = 0; j < LMX; j++)
    if (lvl[a] - lvl[b] & (1 << j)) a = p[a][j];
  if (a == b) return a;
  for (int j = LMX - 1; j >= 0; j--)
    if (p[a][j] != p[b][j]) a = p[a][j], b = p[b][j];
  return p[a][0];
}
void dfs(int u) {
  ini[u] = ++cn;
  for (int v : adj[u]) dfs(v);
  fin[u] = cn;
}
pair<int, int> query(int a, int b) {
  int d = 0;
  for (int j = LMX - 1; j >= 0; j--)
    if (an[a][j] != -1 && lvl[an[a][j]] > lvl[b]) {
      a = an[a][j];
      d |= (1 << j);
    }
  if (an[a][0] == -1 || lvl[an[a][0]] > lvl[b]) return {-1, -1};
  return {d + 1, a};
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> p[i][0];
    lvl[i] = lvl[p[i][0]] + 1;
    adj[p[i][0]].push_back(i);
  }
  p[1][0] = 1;
  for (int j = 1; j < LMX; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  dfs(1);
  cin >> m;
  memset(an, -1, sizeof(an));
  while (m--) {
    cin >> a >> b;
    if (ini[a] > ini[b]) swap(a, b);
    pos[ini[a]].push_back(ini[b]);
    int c = LCA(a, b);
    if (an[a][0] == -1 || lvl[an[a][0]] > lvl[c]) an[a][0] = c;
    if (an[b][0] == -1 || lvl[an[b][0]] > lvl[c]) an[b][0] = c;
  }
  for (int u = n; u > 0; u--)
    for (int v : adj[u])
      if (an[v][0] != -1 && an[v][0] != v)
        if (an[u][0] == -1 || lvl[an[u][0]] > lvl[an[v][0]])
          an[u][0] = an[v][0];
  for (int j = 1; j < LMX; j++)
    for (int i = 1; i <= n; i++)
      if (an[i][j - 1] != -1) an[i][j] = an[an[i][j - 1]][j - 1];
  (st[0] = new PST)->build(1, n);
  for (int i = 1; i <= n; i++) {
    st[i] = st[i - 1];
    for (int j : pos[i]) st[i] = st[i]->update(1, n, j);
  }
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (ini[a] > ini[b]) swap(a, b);
    int c = LCA(a, b);
    int x, y, ra, rb;
    tie(ra, x) = query(a, c);
    tie(rb, y) = query(b, c);
    if (x == -1 || y == -1)
      cout << -1 << '\n';
    else if (a == c || b == c)
      cout << ra + rb - 1 << '\n';
    else {
      int d = st[fin[x]]->query(1, n, ini[y], fin[y]) -
              st[ini[x] - 1]->query(1, n, ini[y], fin[y]);
      cout << ra + rb - bool(d) << '\n';
    }
  }
  return 0;
}