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 = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int n, m, Q, cnt, val, x, y, ind;
int deep[N], in[N], out[N], last[N];
int first[N], ans[N], tr[N];
int fa[N][20], low[N][20];
bool ok[N];
vector<int> a[N], b[N];
struct edge {
  int to, next;
} e[N];
struct chain {
  int x, y, t;
} c[N], q[N];
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
void ins(int u, int v) {
  e[++cnt] = (edge){v, first[u]};
  first[u] = cnt;
}
void dfs(int x) {
  in[x] = ++ind;
  for (int i = 1; (1 << i) <= deep[x]; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = first[x]; i; i = e[i].next) {
    deep[e[i].to] = deep[x] + 1;
    dfs(e[i].to);
  }
  out[x] = ind;
}
int lca(int x, int y) {
  if (deep[x] < deep[y]) swap(x, y);
  int d = deep[x] - deep[y];
  for (int i = 0; (1 << i) <= d; i++)
    if ((1 << i) & d) x = fa[x][i];
  if (x == y) return x;
  for (int i = 17; i >= 0; i--)
    if ((1 << i) <= deep[x] && fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
void dfslow(int x) {
  for (int i = first[x]; i; i = e[i].next) {
    int to = e[i].to;
    dfslow(to);
    if (deep[low[to][0]] < deep[low[x][0]]) low[x][0] = low[to][0];
  }
}
int find(int x, int t) {
  if (deep[low[x][17]] > deep[t]) {
    val = -inf;
    return -1;
  }
  if (x == t) {
    val = -1;
    return 0;
  }
  val = 0;
  for (int i = 17; i >= 0; i--)
    if (deep[low[x][i]] > deep[t]) x = low[x][i], val |= (1 << i);
  return x;
}
int lowbit(int x) { return x & (-x); }
void add(int x, int v) {
  for (; x <= n; x += lowbit(x)) tr[x] += v;
}
int query(int x) {
  int ans = 0;
  for (; x; x -= lowbit(x)) ans += tr[x];
  return ans;
}
void work(int x) {
  for (int sz = b[x].size(), i = 0; i < sz; i++) {
    int t = b[x][i];
    last[t] = query(out[q[t].y]) - query(in[q[t].y] - 1);
  }
  for (int sz = a[x].size(), i = 0; i < sz; i++) add(in[a[x][i]], 1);
  for (int i = first[x]; i; i = e[i].next) work(e[i].to);
  for (int sz = b[x].size(), i = 0; i < sz; i++) {
    int t = b[x][i];
    if (query(out[q[t].y]) - query(in[q[t].y] - 1) != last[t]) ok[t] = true;
  }
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) fa[i][0] = read(), ins(fa[i][0], i);
  dfs(1);
  for (int i = 1; i <= n; i++) low[i][0] = i;
  m = read();
  for (int i = 1; i <= m; i++) {
    c[i].x = read();
    c[i].y = read();
    c[i].t = lca(c[i].x, c[i].y);
    if (deep[c[i].t] < deep[low[c[i].x][0]]) low[c[i].x][0] = c[i].t;
    if (deep[c[i].t] < deep[low[c[i].y][0]]) low[c[i].y][0] = c[i].t;
    a[c[i].x].push_back(c[i].y);
    a[c[i].y].push_back(c[i].x);
  }
  dfslow(1);
  for (int t = 1; t <= n; t++)
    for (int i = 1; i <= 17; i++) low[t][i] = low[low[t][i - 1]][i - 1];
  Q = read();
  for (int i = 1; i <= Q; i++) {
    q[i].x = read();
    q[i].y = read();
    q[i].t = lca(q[i].x, q[i].y);
    ans[i] = 2;
    x = find(q[i].x, q[i].t);
    ans[i] += val;
    y = find(q[i].y, q[i].t);
    ans[i] += val;
    if (x > 0 && y > 0) {
      q[i].x = x;
      q[i].y = y;
      b[x].push_back(i);
    }
  }
  work(1);
  for (int i = 1; i <= Q; i++)
    if (ok[i]) ans[i]--;
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i] < 0 ? -1 : ans[i]);
  return 0;
}