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;
struct node {
  int x, y, t, ans;
  int sum;
} a[200010], bus[200010];
int n, fa[200010][20], dep[200010], low[200010][20], dfnl[200010], dfnr[200010],
    cnt;
vector<int> w[200010], busx[200010], px[200010];
void dfs1(int x) {
  dfnl[x] = ++cnt;
  dep[x] = dep[fa[x][0]] + 1;
  for (int i = 1; i < 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = 0; i < w[x].size(); i++) dfs1(w[x][i]);
  dfnr[x] = cnt;
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
int update(int x, int y) {
  if (dep[x] > dep[y]) return y;
  return x;
}
void dfslow(int x) {
  for (int i = 0; i < w[x].size(); i++) {
    dfslow(w[x][i]);
    low[x][0] = update(low[x][0], low[w[x][i]][0]);
  }
}
pair<int, int> find_low(int x, int y) {
  int res = 0;
  if (dep[low[x][19]] > dep[y]) return make_pair(x, -1);
  for (int i = 19; i >= 0; i--)
    if (dep[low[x][i]] > dep[y]) {
      res += (1 << i);
      x = low[x][i];
    }
  return make_pair(x, res);
}
int tree[200010];
int que(int x) {
  int res = 0;
  while (x > 0) {
    res += tree[x];
    x -= x & (-x);
  }
  return res;
}
int query(int l, int r) { return que(r) - que(l - 1); }
void add(int l, int x) {
  while (l <= n) {
    tree[l] += x;
    l += l & (-l);
  }
}
void dfs(int x) {
  for (int i = 0; i < px[x].size(); i++) {
    int u = px[x][i];
    a[u].sum = query(dfnl[a[u].y], dfnr[a[u].y]);
  }
  for (int i = 0; i < busx[x].size(); i++) {
    int u = busx[x][i];
    if (x == bus[u].x)
      add(dfnl[bus[u].y], 1);
    else
      add(dfnl[bus[u].x], 1);
  }
  for (int i = 0; i < w[x].size(); i++) dfs(w[x][i]);
  for (int i = 0; i < px[x].size(); i++) {
    int u = px[x][i];
    if (a[u].sum == query(dfnl[a[u].y], dfnr[a[u].y])) a[u].ans++;
  }
}
int main() {
  int x, m, u, v, q;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d", &x);
    w[x].push_back(i);
    fa[i][0] = x;
  }
  for (int i = 1; i <= n; i++) low[i][0] = i;
  dep[1] = 1;
  dfs1(1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &u, &v);
    bus[i].x = u, bus[i].y = v;
    bus[i].t = lca(u, v);
    low[u][0] = update(low[u][0], bus[i].t);
    low[v][0] = update(low[v][0], bus[i].t);
    busx[u].push_back(i);
    busx[v].push_back(i);
  }
  dfslow(1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 19; j++) low[i][j] = low[low[i][j - 1]][j - 1];
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    a[i].ans = 1;
    scanf("%d%d", &u, &v);
    if (dep[u] < dep[v]) swap(u, v);
    int t = lca(u, v);
    pair<int, int> res;
    res = find_low(u, t);
    if (res.second == -1) {
      a[i].ans = -1;
      continue;
    }
    a[i].x = res.first;
    a[i].ans += res.second;
    if (t == v) continue;
    res = find_low(v, t);
    if (res.second == -1) {
      a[i].ans = -1;
      continue;
    }
    a[i].y = res.first;
    a[i].ans += res.second;
    px[a[i].x].push_back(i);
  }
  dfs(1);
  for (int i = 1; i <= q; i++) printf("%d\n", a[i].ans);
}