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 N = 200010;
vector<int> ver[N], bus[N];
vector<pair<int, int> > query[N];
int fa[N][18], d[N];
int a[2 * N], st[N], ed[N];
int lowest[N], g[N][18];
int c[2 * N], ans[N], sum[N];
int n, m, q, t;
void add(int x, int y) { ver[x].push_back(y); }
void dfs(int x) {
  a[++t] = x, st[x] = t;
  for (int i = 0; i < ver[x].size(); i++) {
    int y = ver[x][i];
    d[y] = d[x] + 1;
    fa[y][0] = x;
    for (int j = 1; j < 18; j++) fa[y][j] = fa[fa[y][j - 1]][j - 1];
    dfs(y);
  }
  a[++t] = x, ed[x] = t;
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  for (int i = 17; i >= 0; i--)
    if (d[fa[x][i]] >= d[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 17; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void update_lowest(int x, int anc) {
  if (x == anc) return;
  if (lowest[x] == 0 || d[anc] < d[lowest[x]]) lowest[x] = anc;
}
void calc_lowest(int x) {
  for (int i = 0; i < ver[x].size(); i++) {
    int y = ver[x][i];
    calc_lowest(y);
    if (lowest[y]) update_lowest(x, lowest[y]);
  }
}
void binary_lifting_lowest(int x) {
  g[x][0] = lowest[x];
  for (int i = 1; i < 18; i++) g[x][i] = g[g[x][i - 1]][i - 1];
  for (int i = 0; i < ver[x].size(); i++) {
    int y = ver[x][i];
    binary_lifting_lowest(y);
  }
}
pair<int, int> go(int x, int y) {
  int ans = 0;
  for (int i = 17; i >= 0; i--)
    if (d[g[x][i]] > d[y]) x = g[x][i], ans += 1 << i;
  if (d[g[x][0]] == 0)
    return make_pair(-2, 0);
  else
    return make_pair(ans, x);
}
int ask(int x) {
  int ans = 0;
  for (; x; x -= x & -x) ans += c[x];
  return ans;
}
void change(int x, int y) {
  for (; x <= 2 * n; x += x & -x) c[x] += y;
}
void solve(int x) {
  for (int i = 0; i < query[x].size(); i++) {
    int y = query[x][i].first, id = query[x][i].second;
    sum[id] = ask(ed[y]) - ask(st[y]);
  }
  for (int i = 0; i < bus[x].size(); i++) {
    int y = bus[x][i];
    change(ed[y], 1);
  }
  for (int i = 0; i < ver[x].size(); i++) {
    int y = ver[x][i];
    solve(y);
  }
  for (int i = 0; i < query[x].size(); i++) {
    int y = query[x][i].first, id = query[x][i].second;
    if (sum[id] == ask(ed[y]) - ask(st[y])) ans[id]++;
  }
}
int main() {
  cin >> n;
  for (int i = 2, fa; i <= n; i++) {
    scanf("%d", &fa);
    add(fa, i);
  }
  d[1] = 1;
  dfs(1);
  cin >> m;
  for (int i = 1, x, y; i <= m; i++) {
    scanf("%d%d", &x, &y);
    bus[x].push_back(y), bus[y].push_back(x);
    int z = lca(x, y);
    update_lowest(x, z), update_lowest(y, z);
  }
  calc_lowest(1);
  binary_lifting_lowest(1);
  cin >> q;
  for (int i = 1, x, y; i <= q; i++) {
    scanf("%d%d", &x, &y);
    int z = lca(x, y);
    if (x == z) {
      ans[i] = go(y, z).first + 1;
      continue;
    }
    if (y == z) {
      ans[i] = go(x, z).first + 1;
      continue;
    }
    pair<int, int> gx = go(x, z);
    pair<int, int> gy = go(y, z);
    int lx = gx.first, ly = gy.first;
    int px = gx.second, py = gy.second;
    if (lx < 0 || ly < 0)
      ans[i] = -1;
    else {
      ans[i] = lx + ly + 1;
      query[px].push_back(make_pair(py, i));
    }
  }
  solve(1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
}