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;
int n, m, q;
vector<int> G[200010];
vector<int> to[200010];
vector<pair<int, int> > que[200010];
int up[200010][21];
int dep[200010];
int par[200010][21];
int in[200010], out[200010];
int ans[200010];
int cnt;
void dfs(int x) {
  in[x] = ++cnt;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    par[y][0] = x;
    dep[y] = dep[x] + 1;
    dfs(y);
  }
  out[x] = cnt;
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[par[x][i]] >= dep[y]) x = par[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (par[x][i] != par[y][i]) x = par[x][i], y = par[y][i];
  return par[x][0];
}
void update(int x, int y) {
  if (dep[y] < dep[up[x][0]]) up[x][0] = y;
}
int calup(int x) {
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    update(x, calup(y));
  }
  return up[x][0];
}
bool insubt(int x, int y) { return (in[y] >= in[x] && in[y] <= out[x]); }
pair<int, int> calc(int x, int y) {
  int res = 0;
  for (int i = 20; i >= 0; i--) {
    if (!insubt(up[x][i], y)) x = up[x][i], res += (1 << i);
  }
  return make_pair(x, res);
}
int sum[200010];
void add(int x, int v) {
  for (int i = x; i <= n; i += i & -i) sum[i] += v;
}
int query(int x) {
  int res = 0;
  for (int i = x; i; i -= i & -i) res += sum[i];
  return res;
}
int chg[200010];
void solve(int x) {
  for (int i = 0; i < que[x].size(); i++) {
    int y = que[x][i].first, id = que[x][i].second;
    chg[id] = query(out[y]) - query(in[y] - 1);
  }
  for (int i = 0; i < to[x].size(); i++) {
    int y = to[x][i];
    add(in[y], 1);
  }
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i];
    solve(y);
  }
  for (int i = 0; i < que[x].size(); i++) {
    int y = que[x][i].first, id = que[x][i].second;
    if (chg[id] != query(out[y]) - query(in[y] - 1)) ans[id]--;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    G[x].push_back(i);
  }
  dep[0] = -1;
  dfs(1);
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) par[j][i] = par[par[j][i - 1]][i - 1];
  }
  for (int i = 1; i <= n; i++) up[i][0] = i;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int xy = lca(x, y);
    update(x, xy);
    update(y, xy);
    to[x].push_back(y);
    to[y].push_back(x);
  }
  calup(1);
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) up[j][i] = up[up[j][i - 1]][i - 1];
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int xy = lca(x, y);
    if (!insubt(up[x][20], xy) || !insubt(up[y][20], xy)) {
      ans[i] = -1;
      continue;
    }
    pair<int, int> r1 = calc(x, xy);
    pair<int, int> r2 = calc(y, xy);
    x = r1.first;
    y = r2.first;
    ans[i] = r1.second + r2.second;
    if (x == xy || y == xy)
      ans[i]++;
    else {
      ans[i] += 2;
      que[x].push_back(make_pair(y, i));
    }
  }
  solve(1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}