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 = 200005;
int n, m, Q, f[20][N], g[20][N], hd[N], nx[N], dep[N], in[N], ot[N], tim, c[N],
    ans[N], tmp[N];
vector<pair<int, int> > p[N];
vector<int> s[N];
inline void read(int &i) {
  i = 0;
  char c = getchar();
  bool j = 0;
  for (; !isdigit(c); c = getchar())
    if (c == '-') j = 1;
  for (; isdigit(c); c = getchar()) i = (i << 1) + (i << 3) + c - '0';
  i = j ? -i : i;
}
inline void up(int &x, int y) {
  if (!x || !y)
    x |= y;
  else
    x = dep[x] < dep[y] ? x : y;
}
inline void mdf(int x) {
  while (x <= n) c[x]++, x += x & (-x);
}
inline int qry(int x) {
  int r = 0;
  while (x) r += c[x], x ^= x & (-x);
  return r;
}
inline int qry(int l, int r) { return qry(r) - qry(l - 1); }
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int d = dep[x] - dep[y];
  for (int i = 19; ~i; --i)
    if (1 << i <= d) d -= 1 << i, x = f[i][x];
  if (x == y) return x;
  for (int i = 19; ~i; --i)
    if (f[i][x] != f[i][y]) x = f[i][x], y = f[i][y];
  return f[0][x];
}
void dfs1(int x, int fa) {
  f[0][x] = fa;
  dep[x] = dep[fa] + 1;
  in[x] = ++tim;
  for (int y = hd[x]; y; y = nx[y]) dfs1(y, x);
  ot[x] = tim;
}
void dfs2(int x) {
  for (int y = hd[x]; y; y = nx[y]) {
    dfs2(y);
    up(g[0][x], g[0][y]);
  }
  if (g[0][x] == x) g[0][x] = 0;
}
inline pair<int, int> bus(int x, int y) {
  pair<int, int> t;
  t.second = 0;
  for (int i = 19; ~i; --i)
    if (g[i][x] && dep[g[i][x]] > dep[y]) x = g[i][x], t.second += 1 << i;
  t.first = x;
  return t;
}
void dfs3(int x) {
  for (pair<int, int> t : p[x]) tmp[t.second] = qry(in[t.first], ot[t.first]);
  for (int t : s[x]) mdf(in[t]);
  for (int y = hd[x]; y; y = nx[y]) dfs3(y);
  for (pair<int, int> t : p[x])
    if (qry(in[t.first], ot[t.first]) - tmp[t.second] == 0) ans[t.second]++;
}
int main() {
  read(n);
  for (int i = 2, x; i <= n; ++i) read(x), nx[i] = hd[x], hd[x] = i;
  dfs1(1, 0);
  for (int i = 1; i <= 19; ++i)
    for (int j = 1; j <= n; ++j) f[i][j] = f[i - 1][f[i - 1][j]];
  read(m);
  for (int i = 1, x, y, z; i <= m; ++i) {
    read(x), read(y);
    if (in[x] > in[y]) swap(x, y);
    z = lca(x, y);
    s[x].push_back(y);
    up(g[0][x], z);
    up(g[0][y], z);
  }
  dfs2(1);
  for (int i = 1; i <= 19; ++i)
    for (int j = 1; j <= n; ++j) g[i][j] = g[i - 1][g[i - 1][j]];
  read(Q);
  for (int i = 1, x, y, z; i <= Q; ++i) {
    read(x);
    read(y);
    if (in[x] > in[y]) swap(x, y);
    z = lca(x, y);
    if (z == x) {
      pair<int, int> p = bus(y, x);
      if (g[0][p.first])
        ans[i] = p.second + 1;
      else
        ans[i] = -1;
    } else {
      pair<int, int> px = bus(x, z);
      pair<int, int> py = bus(y, z);
      if (g[0][px.first] && g[0][py.first])
        ans[i] = px.second + py.second + 1,
        p[px.first].push_back(pair<int, int>(py.first, i));
      else
        ans[i] = -1;
    }
  }
  dfs3(1);
  for (int i = 1; i <= Q; ++i) printf("%d\n", ans[i]);
  return 0;
}