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 long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 201000;
int p[N][20], x, y, n, m, q, dep[N], go[N][20], mind[N][20];
set<pair<int, int> > pool[N];
set<pair<int, int> >* ins[N];
vector<int> e[N];
int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  for (int i = 18 - 1; i >= 0; i--)
    if (dep[p[v][i]] >= dep[u]) v = p[v][i];
  if (u == v) return u;
  for (int i = 18 - 1; i >= 0; i--)
    if (p[v][i] != p[u][i]) u = p[u][i], v = p[v][i];
  return p[u][0];
}
void upd(int& a, int b) {
  if (dep[b] < dep[a]) a = b;
}
int tot, l[N], r[N], c[N], vis[N], cur[N], ret[N];
void dfs(int u, int f) {
  l[u] = ++tot;
  for (auto v : e[u]) dfs(v, u);
  r[u] = tot;
}
void modify(int x, int s) {
  for (; x <= n; x += x & -x) c[x] += s;
}
int query(int x) {
  int s = 0;
  for (; x; x -= x & -x) s += c[x];
  return s;
}
vector<pair<int, pair<int, int> > > evt;
int main() {
  scanf("%d", &n);
  dep[1] = 1;
  for (int i = 2; i < n + 1; i++) {
    scanf("%d", &x);
    p[i][0] = x;
    dep[i] = dep[x] + 1;
    e[x].push_back(i);
  }
  dfs(1, 0);
  for (int j = 1; j < 18; j++)
    for (int i = 1; i < n + 1; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  scanf("%d", &m);
  for (int i = 1; i < n + 1; i++) go[i][0] = i;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    int w = lca(x, y);
    upd(go[x][0], w);
    upd(go[y][0], w);
    evt.push_back(make_pair(l[x], make_pair(-1e9, l[y])));
    evt.push_back(make_pair(l[y], make_pair(-1e9, l[x])));
  }
  for (int i = n + 1 - 1; i >= 2; i--) upd(go[p[i][0]][0], go[i][0]);
  for (int k = 1; k < 18; k++)
    for (int i = 1; i <= n; i++) {
      go[i][k] = go[i][k - 1];
      upd(go[i][k], go[go[i][k - 1]][k - 1]);
    }
  scanf("%d", &q);
  for (int i = 1; i < q + 1; i++) {
    scanf("%d%d", &x, &y);
    int w = lca(x, y);
    if (dep[go[x][18 - 1]] > dep[w] || dep[go[y][18 - 1]] > dep[w]) {
      ret[i] = -1;
      continue;
    }
    for (int j = 18 - 1; j >= 0; j--)
      if (dep[go[x][j]] > dep[w]) {
        x = go[x][j];
        ret[i] += (1 << j);
      }
    for (int j = 18 - 1; j >= 0; j--)
      if (dep[go[y][j]] > dep[w]) {
        y = go[y][j];
        ret[i] += (1 << j);
      }
    if (w == x || w == y) {
      ret[i]++;
      continue;
    }
    vis[i] = 1;
    evt.push_back(make_pair(l[x] - 1, make_pair(i, l[y] - 1)));
    evt.push_back(make_pair(l[x] - 1, make_pair(-i, r[y])));
    evt.push_back(make_pair(r[x], make_pair(-i, l[y] - 1)));
    evt.push_back(make_pair(r[x], make_pair(i, r[y])));
  }
  sort((evt).begin(), (evt).end());
  for (auto p : evt) {
    int id = p.second.first, y = p.second.second;
    if (id < -q) {
      modify(y, 1);
    } else {
      if (id > 0)
        cur[id] += query(y);
      else
        cur[-id] -= query(y);
    }
  }
  for (int i = 1; i < q + 1; i++)
    if (vis[i]) {
      if (cur[i])
        ret[i]++;
      else
        ret[i] += 2;
    }
  for (int i = 1; i < q + 1; i++) printf("%d\n", ret[i]);
}