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, h[200020], grand[200020][19], from, to, c[200020], t, size[200020],
    up[200020][19], tmp[200020], ans[200020];
vector<int> v[200020];
vector<pair<int, int> > g[200020];
int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x;
}
struct xx {
  int next, to;
} way[200020];
int num, head[200020], dfn[200020];
void add(int from, int to) {
  way[++num].next = head[from];
  way[num].to = to;
  head[from] = num;
}
void dfs(int x) {
  dfn[x] = ++t;
  size[x] = 1;
  h[x] = h[grand[x][0]] + 1;
  for (int j = 1; j <= 17; j++) grand[x][j] = grand[grand[x][j - 1]][j - 1];
  for (int i = head[x]; i; i = way[i].next) {
    int y = way[i].to;
    dfs(y);
    size[x] += size[y];
  }
}
int lcaa(int x, int y) {
  if (h[x] > h[y]) swap(x, y);
  for (int j = 17; j >= 0; j--)
    if (h[grand[y][j]] >= h[x]) y = grand[y][j];
  if (x == y) return x;
  for (int j = 17; j >= 0; j--) {
    if (grand[x][j] != grand[y][j]) {
      x = grand[x][j];
      y = grand[y][j];
    }
  }
  return grand[x][0];
}
void pre() {
  for (int i = n; i >= 1; --i) {
    up[i][0] = i;
    for (int j = head[i]; j; j = way[j].next) {
      int y = way[j].to;
      if (h[up[i][0]] > h[up[y][0]]) up[i][0] = up[y][0];
    }
    for (int j = 0; j < (int)v[i].size(); ++j) {
      int y = lcaa(v[i][j], i);
      if (h[y] < h[up[i][0]]) up[i][0] = y;
    }
  }
  for (int j = 1; j <= 17; j++)
    for (int i = 1; i <= n; i++) up[i][j] = up[up[i][j - 1]][j - 1];
}
void add(int x) {
  for (; x <= n; x += x & -x) c[x]++;
}
int ask(int x) {
  int y = 0;
  for (; x; x -= x & -x) y += c[x];
  return y;
}
void work(int x) {
  for (int i = 0; i < (int)g[x].size(); i++)
    tmp[g[x][i].second] = ask(dfn[g[x][i].first] + size[g[x][i].first] - 1) -
                          ask(dfn[g[x][i].first] - 1);
  for (int i = 0; i < (int)v[x].size(); i++) add(dfn[v[x][i]]);
  for (int i = head[x]; i; i = way[i].next) work(way[i].to);
  for (int i = 0; i < (int)g[x].size(); i++) {
    if ((ask(dfn[g[x][i].first] + size[g[x][i].first] - 1) -
         ask(dfn[g[x][i].first] - 1)) == tmp[g[x][i].second])
      ans[g[x][i].second]++;
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) {
    grand[i][0] = read();
    add(grand[i][0], i);
  }
  int m = read();
  for (int i = 1; i <= m; i++) {
    from = read();
    to = read();
    v[from].push_back(to);
    v[to].push_back(from);
  }
  dfs(1);
  pre();
  int q = read();
  for (int i = 1; i <= q; i++) {
    int x = read();
    int y = read();
    int lca = lcaa(x, y);
    for (int j = 17; j >= 0; j--) {
      if (h[up[x][j]] > h[lca]) x = up[x][j], ans[i] += (1 << j);
      if (h[up[y][j]] > h[lca]) y = up[y][j], ans[i] += (1 << j);
    }
    if (h[up[x][0]] > h[lca] || h[up[y][0]] > h[lca]) {
      ans[i] = -1;
      continue;
    }
    ans[i]++;
    if (x != lca && y != lca) g[x].push_back(make_pair(y, i));
  }
  work(1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}