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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  int s = 0, f = 0;
  char c;
  while (!isdigit(c)) {
    f |= (c == '-');
    c = gc();
  }
  while (isdigit(c)) {
    s = s * 10 + c - '0';
    c = gc();
  }
  return f ? -s : s;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(int x) {
  write(x);
  puts("");
}
const int N = 200005, M = 400005;
int n, m, Q, tot = 0, Next[M], to[M], head[M], in[N], out[N], tim = 0, F[N][23],
             dep[N], up[N][23], re[N], pp[N];
int ct = 0;
struct node {
  int l, r, id, op;
} a[N * 5];
inline bool cmp(node a, node b) {
  return (a.l != b.l) ? (a.l < b.l) : (a.id < b.id);
}
inline void add(int x, int y) {
  Next[++tot] = head[x];
  to[tot] = y;
  head[x] = tot;
}
namespace LCA {
inline void dfs(int x, int fa) {
  int i;
  in[x] = ++tim;
  for (i = head[x]; i; i = Next[i])
    if (to[i] != fa) {
      dep[to[i]] = dep[x] + 1;
      F[to[i]][0] = x;
      dfs(to[i], x);
    }
  out[x] = tim;
}
inline void init() {
  int i, j;
  dep[1] = 1;
  dfs(1, 0);
  for (i = 1; i <= 19; i++)
    for (j = 1; j <= n; j++) F[j][i] = F[F[j][i - 1]][i - 1];
}
inline int ask(int x, int y) {
  int i;
  if (dep[x] < dep[y]) swap(x, y);
  for (i = 19; ~i; i--)
    if (dep[F[x][i]] >= dep[y]) x = F[x][i];
  if (x == y) return x;
  for (i = 19; ~i; i--)
    if (F[x][i] != F[y][i]) {
      x = F[x][i];
      y = F[y][i];
    }
  return F[x][0];
}
}  // namespace LCA
inline void dfs(int x, int fa) {
  int i;
  for (i = head[x]; i; i = Next[i])
    if (to[i] != fa) {
      dfs(to[i], x);
      if (up[to[i]][0] && (!up[x][0] || (dep[up[to[i]][0]] < dep[up[x][0]])))
        up[x][0] = up[to[i]][0];
    }
}
struct tree {
  int t[N];
  inline void init() { memset(t, 0, sizeof t); }
  inline void ins(int x) {
    while (x <= n) {
      t[x]++;
      x += ((x) & (-x));
    }
  }
  inline int que(int x) {
    int rr = 0;
    while (x) {
      rr += t[x];
      x -= ((x) & (-x));
    }
    return rr;
  }
} T;
int main() {
  int i, j, x, y, ll;
  n = read();
  for (i = 2; i <= n; i++) {
    x = read();
    add(i, x);
    add(x, i);
  }
  m = read();
  LCA::init();
  for (i = 1; i <= m; i++) {
    x = read();
    y = read();
    ll = LCA::ask(x, y);
    if (in[x] > in[y]) swap(x, y);
    if (!up[x][0] || (dep[ll] < dep[up[x][0]])) up[x][0] = ll;
    if (!up[y][0] || (dep[ll] < dep[up[y][0]])) up[y][0] = ll;
    a[++ct] = (node){in[x], in[y], 0, 1};
  }
  dfs(1, 0);
  for (i = 1; i <= n; i++)
    if (up[i][0] == i) up[i][0] = 0;
  for (i = 1; i <= 19; i++) {
    for (j = 1; j <= n; j++) up[j][i] = up[up[j][i - 1]][i - 1];
  }
  Q = read();
  for (i = 1; i <= Q; i++) {
    x = read();
    y = read();
    if (in[x] > in[y]) swap(x, y);
    ll = LCA::ask(x, y);
    for (j = 19; ~j; j--)
      if (dep[up[x][j]] > dep[ll]) {
        x = up[x][j];
        re[i] += (1 << j);
      }
    if (x != ll && up[x][0] == 0) {
      re[i] = -1;
      continue;
    }
    for (j = 19; ~j; j--)
      if (dep[up[y][j]] > dep[ll]) {
        y = up[y][j];
        re[i] += (1 << j);
      }
    if (y != ll && up[y][0] == 0) {
      re[i] = -1;
      continue;
    }
    if (x == ll || y == ll)
      re[i]++;
    else {
      re[i] += 2;
      a[++ct] = (node){out[x], out[y], i, 1};
      a[++ct] = (node){in[x] - 1, out[y], i, -1};
      a[++ct] = (node){out[x], in[y] - 1, i, -1};
      a[++ct] = (node){in[x] - 1, in[y] - 1, i, 1};
    }
  }
  sort(a + 1, a + ct + 1, cmp);
  T.init();
  for (i = 1; i <= ct; i++) {
    if (a[i].id) {
      pp[a[i].id] += a[i].op * T.que(a[i].r);
    } else
      T.ins(a[i].r);
  }
  for (i = 1; i <= Q; i++) {
    if (~re[i]) re[i] -= (pp[i] > 0);
    writeln(re[i]);
  }
}