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;
struct Edge {
  int u, v, Next;
} G[200010];
int head[200010], tot;
int in[200010], out[200010], dfs_clock;
int lowest[200010];
int h[200010];
int ft[200010][20];
int low[200010][20];
inline void add(int u, int v) {
  G[++tot] = (Edge){u, v, head[u]};
  head[u] = tot;
}
inline void dfs(int x, int fa) {
  h[x] = h[fa] + 1;
  ft[x][0] = fa;
  in[x] = ++dfs_clock;
  for (int i = 1; i <= 19; ++i) {
    ft[x][i] = ft[ft[x][i - 1]][i - 1];
  }
  for (int i = head[x]; i != -1; i = G[i].Next) {
    dfs(G[i].v, x);
  }
  out[x] = dfs_clock;
}
inline int lca(int x, int y) {
  if (h[x] < h[y]) swap(x, y);
  int t = h[x] - h[y];
  for (int i = 0; i <= 19; ++i) {
    if ((1 << i) & t) {
      x = ft[x][i];
    }
  }
  if (x == y) return x;
  for (int i = 19; i >= 0; --i) {
    if (ft[x][i] != ft[y][i]) {
      x = ft[x][i];
      y = ft[y][i];
    }
  }
  return ft[x][0];
}
inline void dfs_low(int x, int fa) {
  for (int i = head[x]; i != -1; i = G[i].Next) {
    dfs_low(G[i].v, x);
    if (h[lowest[G[i].v]] < h[lowest[x]]) {
      lowest[x] = lowest[G[i].v];
    }
  }
}
bool ban[200010];
inline bool is_(int x, int y) { return (in[x] <= in[y] && out[y] <= out[x]); }
inline bool reachable(int x, int LCA) {
  x = low[x][19];
  return is_(x, LCA);
}
int ans[200010], cnt[200010];
vector<pair<int, int> > que[200010];
vector<int> bus[200010];
int C[200010];
inline void add(int x) {
  for (int i = x; i <= n; i += (i & -i)) {
    C[i]++;
  }
}
inline int query(int l, int r) {
  int ret = 0;
  for (; r; r -= (r & -r)) {
    ret += C[r];
  }
  --l;
  for (; l; l -= (l & -l)) {
    ret -= C[l];
  }
  return ret;
}
inline void Do(int x) {
  for (int i = 0; i < que[x].size(); ++i) {
    int X = que[x][i].first, y = que[x][i].second;
    cnt[y] -= query(in[X], out[X]);
  }
  for (int i = 0; i < bus[x].size(); ++i) {
    add(in[bus[x][i]]);
  }
  for (int i = head[x]; i != -1; i = G[i].Next) {
    Do(G[i].v);
  }
  for (int i = 0; i < que[x].size(); ++i) {
    int X = que[x][i].first, y = que[x][i].second;
    cnt[y] += query(in[X], out[X]);
    if (cnt[y] > 0) {
      ans[y]--;
    }
  }
}
int main() {
  scanf("%d", &n);
  memset(head, -1, sizeof(head));
  for (int i = 2; i <= n; ++i) {
    int p;
    scanf("%d", &p);
    add(p, i);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; ++i) {
    lowest[i] = i;
  }
  int m;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    bus[u].push_back(v);
    bus[v].push_back(u);
    int LCA = lca(u, v);
    lowest[u] = (h[lowest[u]] < h[LCA] ? lowest[u] : LCA);
    lowest[v] = (h[lowest[v]] < h[LCA] ? lowest[v] : LCA);
  }
  dfs_low(1, 0);
  for (int i = 1; i <= n; ++i) {
    low[i][0] = lowest[i];
  }
  for (int i = 1; i <= 19; ++i) {
    for (int j = 1; j <= n; ++j) {
      low[j][i] = low[low[j][i - 1]][i - 1];
    }
  }
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    int LCA = lca(u, v);
    if (!reachable(u, LCA) || !reachable(v, LCA)) {
      ban[i] = true;
    }
    for (int j = 19; j >= 0; --j) {
      if (!is_(low[u][j], v)) {
        u = low[u][j];
        ans[i] += (1 << j);
      }
    }
    for (int j = 19; j >= 0; --j) {
      if (!is_(low[v][j], u)) {
        v = low[v][j];
        ans[i] += (1 << j);
      }
    }
    if (u != LCA && v != LCA) {
      que[u].push_back(make_pair(v, i));
    }
    ans[i] += (v != LCA);
    ans[i] += (u != LCA);
  }
  Do(1);
  for (int i = 1; i <= q; ++i) {
    if (ban[i])
      puts("-1");
    else
      printf("%d\n", ans[i]);
  }
}