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 _max(int x, int y) { return x > y ? x : y; }
int _min(int x, int y) { return x < y ? x : y; }
int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
struct edge {
  int x, y, next;
} e[410000];
int len, last[410000];
int n, id, dep[210000], fa[20][210000], up[20][210000], ll[210000], rr[210000];
int hh, ans[210000], sv[210000], pp[210000];
vector<int> q[210000], g[210000];
bool v[210000];
int s[210000];
int lowbit(int x) { return x & -x; }
void change(int x, int c) {
  for (int i = x; i <= n; i += lowbit(i)) s[i] += c;
}
int getsum(int x) {
  int sum = 0;
  for (int i = x; i; i -= lowbit(i)) sum += s[i];
  return sum;
}
void ins(int x, int y) {
  e[++len].x = x, e[len].y = y;
  e[len].next = last[x], last[x] = len;
}
void dfs(int x) {
  ll[x] = ++id;
  for (int i = 1; (1 << i) <= dep[x]; i++) fa[i][x] = fa[i - 1][fa[i - 1][x]];
  for (int k = last[x]; k; k = e[k].next) {
    int y = e[k].y;
    fa[0][y] = x, dep[y] = dep[x] + 1, dfs(y);
  }
  rr[x] = id;
}
void get_up(int x) {
  for (int k = last[x]; k; k = e[k].next) {
    int y = e[k].y;
    get_up(y);
    if (up[0][y] != -1 && ((up[0][x] == -1 && dep[up[0][y]] < dep[x]) ||
                           dep[up[0][y]] < dep[up[0][x]]))
      up[0][x] = up[0][y];
  }
}
void solve(int x) {
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    sv[y] = getsum(rr[pp[y]]) - getsum(ll[pp[y]] - 1);
  }
  for (int i = 0; i < q[x].size(); i++) {
    int y = q[x][i];
    change(ll[y], 1);
  }
  for (int k = last[x]; k; k = e[k].next) solve(e[k].y);
  for (int i = 0; i < g[x].size(); i++) {
    int y = g[x][i];
    if (sv[y] != getsum(rr[pp[y]]) - getsum(ll[pp[y]] - 1)) v[y] = 1;
  }
}
int LCA(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--)
    if (dep[y] - dep[x] >= (1 << i)) {
      y = fa[i][y];
    }
  if (x == y) return x;
  for (int i = 18; i >= 0; i--)
    if (fa[i][x] != fa[i][y]) {
      x = fa[i][x], y = fa[i][y];
    }
  return fa[0][x];
}
bool get_x(int &x, int lca) {
  for (int i = 18; i >= 0; i--)
    if (up[i][x] != -1 && dep[up[i][x]] > dep[lca]) {
      x = up[i][x], hh += 1 << i;
    }
  if (up[0][x] == -1 && x != lca) return 0;
  return 1;
}
int main() {
  n = read();
  for (int i = 2; i <= n; i++) ins(read(), i);
  dep[1] = 1;
  dfs(1);
  int m = read();
  memset(up, -1, sizeof(up));
  up[0][1] = 0;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    int lca = LCA(x, y);
    if (lca != x && (up[0][x] == -1 || dep[up[0][x]] > dep[lca]))
      up[0][x] = lca;
    if (lca != y && (up[0][y] == -1 || dep[up[0][y]] > dep[lca]))
      up[0][y] = lca;
    q[x].push_back(y), q[y].push_back(x);
  }
  get_up(1);
  for (int i = 1; i <= 18; i++)
    for (int x = 1; x <= n; x++)
      if (up[i - 1][x] != -1) up[i][x] = up[i - 1][up[i - 1][x]];
  memset(v, 1, sizeof(v));
  int Q = read();
  for (int i = 1; i <= Q; i++) {
    int x = read(), y = read();
    int lca = LCA(x, y);
    ans[i] = 2;
    hh = 0, get_x(x, lca) ? ans[i] += hh : ans[i] = -999999999;
    hh = 0, get_x(y, lca) ? ans[i] += hh : ans[i] = -999999999;
    if (x != lca && y != lca) g[x].push_back(i), pp[i] = y, v[i] = 0;
  }
  solve(1);
  for (int i = 1; i <= Q; i++) ans[i] -= v[i] == 1;
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i] < 0 ? -1 : ans[i]);
  return 0;
}