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 Maxn = 200005;
int n, m, Q, sign, tot;
int h[Maxn], dep[Maxn], p[Maxn][20], L[Maxn], R[Maxn], upper[Maxn][20];
int fa[Maxn], ans[Maxn], cnt[Maxn], tr[Maxn];
void add(int x, int val) {
  for (int i = x; i <= n; i += i & -i) tr[i] += val;
}
int ask(int x) {
  int ret = 0;
  for (int i = x; i; i -= i & -i) ret += tr[i];
  return ret;
}
struct edge {
  int to, next;
} e[Maxn * 2];
struct node {
  int x, y, lca, id;
} b[Maxn], q[Maxn];
struct info {
  int x, l, r, f, id;
  bool operator<(const info& b) const {
    return x < b.x || (x == b.x && f < b.f);
  }
} w[Maxn * 6];
void addedge(int x, int y) {
  static int cnt;
  e[++cnt] = (edge){y, h[x]};
  h[x] = cnt;
}
void dfs(int x, int fa) {
  dep[x] = dep[fa] + 1;
  p[x][0] = fa;
  L[x] = ++sign;
  for (int i = 1; i <= 17; i++) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = h[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fa) continue;
    dfs(y, x);
  }
  R[x] = sign;
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 17; ~i; i--)
    if (dep[p[x][i]] >= dep[y]) x = p[x][i];
  if (x == y) return x;
  for (int i = 17; ~i; i--)
    if (p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
void dfs2(int x, int fa) {
  for (int i = h[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fa) continue;
    dfs2(y, x);
    if (dep[upper[y][0]] < dep[upper[x][0]]) upper[x][0] = upper[y][0];
  }
}
void dfs3(int x, int fa) {
  for (int i = 1; i <= 17; i++) upper[x][i] = upper[upper[x][i - 1]][i - 1];
  for (int i = h[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fa) continue;
    dfs3(y, x);
  }
}
pair<int, int> ask(int x, int y) {
  int ans = 0;
  for (int i = 17; ~i; i--)
    if (dep[upper[x][i]] > dep[y]) x = upper[x][i], ans |= 1 << i;
  return make_pair(x, ans);
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    addedge(x, i);
    addedge(i, x);
  }
  for (int i = 1; i <= n; i++) fa[i] = i;
  dfs(1, 0);
  for (int i = 1; i <= n; i++) upper[i][0] = i;
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y, lca;
    scanf("%d%d", &x, &y);
    if (L[x] > L[y]) swap(x, y);
    lca = ::lca(x, y);
    if (dep[upper[x][0]] > dep[lca]) upper[x][0] = lca;
    if (dep[upper[y][0]] > dep[lca]) upper[y][0] = lca;
    b[i] = (node){x, y, lca};
    w[++tot] = (info){L[x], L[y], 0, 1, 0};
    w[++tot] = (info){L[y], L[x], 0, 1, 0};
    x = find(x);
    y = find(y);
    while (x != y) {
      if (dep[x] < dep[y]) swap(x, y);
      x = fa[x] = find(p[x][0]);
    }
  }
  dfs2(1, 0);
  dfs3(1, 0);
  scanf("%d", &Q);
  for (int i = 1; i <= Q; i++) {
    int x, y, lca, px, py;
    pair<int, int> ret;
    scanf("%d%d", &x, &y);
    if (L[x] > L[y]) swap(x, y);
    lca = ::lca(x, y);
    q[i] = (node){x, y, lca, i};
    ret = ask(x, lca);
    ans[i] += ret.second;
    px = ret.first;
    ret = ask(y, lca);
    ans[i] += ret.second;
    py = ret.first;
    if (x != lca && y != lca) {
      w[++tot] = (info){L[px], L[py], R[py], 0, i};
      w[++tot] = (info){R[px], L[py], R[py], 2, i};
    } else
      ans[i]++;
  }
  sort(w + 1, w + tot + 1);
  for (int i = 1; i <= tot; i++) {
    if (w[i].f == 0) cnt[w[i].id] -= ask(w[i].r) - ask(w[i].l - 1);
    if (w[i].f == 1) add(w[i].l, 1);
    if (w[i].f == 2) {
      cnt[w[i].id] += ask(w[i].r) - ask(w[i].l - 1);
      if (cnt[w[i].id])
        ans[w[i].id]++;
      else
        ans[w[i].id] += 2;
    }
  }
  for (int i = 1; i <= Q; i++) {
    if (find(q[i].x) == find(q[i].y))
      cout << ans[i] << "\n";
    else
      puts("-1");
  }
}