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 read() {
  char ch;
  for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar())
    ;
  int x = ch - '0';
  for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar())
    x = x * 10 + ch - '0';
  return x;
}
void write(int x) {
  if (!x) {
    puts("0");
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  char ch[20];
  int tot = 0;
  for (; x; x /= 10) ch[++tot] = x % 10 + '0';
  for (int i = tot; i >= 1; i--) putchar(ch[i]);
  puts("");
}
const int N = 4e5 + 5;
int t[N], nxt[N], lst[N], l;
void add(int x, int y) {
  t[++l] = y;
  nxt[l] = lst[x];
  lst[x] = l;
}
vector<int> vec[N];
vector<pair<int, int> > que[N];
int n, m, q, tot, fa[N][18], up[N][18], dep[N], dfn[N], sz[N], tmp[N], an[N];
void dfs(int x) {
  dep[x] = dep[fa[x][0]] + 1;
  dfn[x] = ++tot;
  sz[x] = 1;
  for (int j = 1; j <= 17; j++) fa[x][j] = fa[fa[x][j - 1]][j - 1];
  for (int i = lst[x]; i; i = nxt[i]) dfs(t[i]), sz[x] += sz[t[i]];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int j = 17; j >= 0; j--)
    if (dep[fa[x][j]] > dep[y]) x = fa[x][j];
  x = dep[x] == dep[y] ? x : fa[x][0];
  for (int j = 17; j >= 0; j--)
    if (fa[x][j] != fa[y][j]) x = fa[x][j], y = fa[y][j];
  return x == y ? x : fa[x][0];
}
void prepare() {
  for (int i = n; i >= 1; i--) {
    up[i][0] = i;
    for (int j = lst[i]; j; j = nxt[j])
      up[i][0] = dep[up[t[j]][0]] < dep[up[i][0]] ? up[t[j]][0] : up[i][0];
    for (int j = 0; j < vec[i].size(); j++) {
      int x = lca(vec[i][j], i);
      up[i][0] = dep[x] < dep[up[i][0]] ? x : up[i][0];
    }
  }
  for (int j = 1; j <= 17; j++)
    for (int i = 1; i <= n; i++) up[i][j] = up[up[i][j - 1]][j - 1];
}
int tr[N];
void I(int x) {
  for (; x <= n; x += x & -x) tr[x]++;
}
int Q(int x) {
  int res = 0;
  for (; x; x -= x & -x) res += tr[x];
  return res;
}
void solve(int x) {
  for (int i = 0; i < que[x].size(); i++) {
    int y = que[x][i].first, id = que[x][i].second;
    tmp[id] = Q(dfn[y] + sz[y] - 1) - Q(dfn[y] - 1);
  }
  for (int i = 0; i < vec[x].size(); i++) I(dfn[vec[x][i]]);
  for (int i = lst[x]; i; i = nxt[i]) solve(t[i]);
  for (int i = 0; i < que[x].size(); i++) {
    int y = que[x][i].first, id = que[x][i].second;
    an[id] += (Q(dfn[y] + sz[y] - 1) - Q(dfn[y] - 1)) == tmp[id];
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) {
    fa[i][0] = read();
    add(fa[i][0], i);
  }
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  dfs(1);
  prepare();
  q = read();
  for (int i = 1; i <= q; i++) {
    int x = read(), y = read(), z = lca(x, y);
    an[i] = 1;
    for (int j = 17; j >= 0; j--) {
      if (dep[up[x][j]] > dep[z]) x = up[x][j], an[i] += 1 << j;
      if (dep[up[y][j]] > dep[z]) y = up[y][j], an[i] += 1 << j;
    }
    if (dep[up[x][0]] > dep[z] || dep[up[y][0]] > dep[z]) {
      an[i] = -1;
      continue;
    }
    if (x != z && y != z) que[x].push_back(make_pair(y, i));
  }
  solve(1);
  for (int i = 1; i <= q; i++) write(an[i]);
  return 0;
}