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 MAX = 212345;
vector<int> edge[MAX];
vector<int> end_path[MAX];
vector<pair<int, int> > query_pair[MAX];
vector<int> store;
int ans[MAX];
int dep[MAX], f[MAX][20], lb[MAX], rb[MAX], tot;
int jump[MAX][20], go[MAX];
int n;
long long tree[MAX * 4];
void add(int y) {
  while (y < MAX * 4) {
    tree[y] += 1;
    y += y & (-y);
  }
}
long long query(int y) {
  long long sum = 0;
  while (y) {
    sum += tree[y];
    y -= y & (-y);
  }
  return sum;
}
long long get(int l, int r) { return query(r) - query(l - 1); }
void dfs_lca(int u, int fa, int depth) {
  lb[u] = ++tot;
  dep[u] = depth + 1;
  f[u][0] = fa;
  for (auto v : edge[u]) {
    if (v == fa) continue;
    dfs_lca(v, u, depth + 1);
  }
  rb[u] = tot;
}
void init_LCA() {
  dfs_lca(1, 0, 0);
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      f[j][i] = f[f[j][i - 1]][i - 1];
    }
  }
}
int LCA(int u, int v) {
  if (dep[v] > dep[u]) swap(u, v);
  int diff = dep[u] - dep[v];
  for (int i = 19; i >= 0; i--) {
    if (diff >> i & 1) u = f[u][i];
  }
  if (u == v) return u;
  for (int i = 19; i >= 0; i--) {
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  }
  return f[u][0];
}
void dfs_jump(int u, int fa) {
  store.push_back(u);
  for (auto v : edge[u]) {
    if (v == fa) continue;
    dfs_jump(v, u);
    go[u] = max(go[u], go[v] - 1);
  }
  jump[u][0] = *(store.end() - go[u] - 1);
  store.pop_back();
}
void init_jump() {
  dfs_jump(1, 0);
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      jump[j][i] = jump[jump[j][i - 1]][i - 1];
    }
  }
}
int eu, ev;
int JUMP(int u, int v, int x) {
  if (jump[u][19] != jump[v][19]) return -1e9;
  int rst = 0;
  for (int i = 19; i >= 0; i--) {
    if (dep[jump[u][i]] > x) {
      rst += (1 << i);
      u = jump[u][i];
    }
    if (dep[jump[v][i]] > x) {
      rst += (1 << i);
      v = jump[v][i];
    }
  }
  eu = u;
  ev = v;
  return rst;
}
void solve(int u, int fa) {
  vector<long long> store;
  for (auto v : query_pair[u]) store.push_back(get(lb[v.second], rb[v.second]));
  for (auto v : end_path[u]) add(lb[v]);
  for (auto v : edge[u]) {
    if (v == fa) continue;
    solve(v, u);
  }
  for (int i = 0; i < query_pair[u].size(); i++) {
    int v = query_pair[u][i].second;
    int id = query_pair[u][i].first;
    if (store[i] != get(lb[v], rb[v])) ans[id]--;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    int x;
    scanf("%d", &x);
    edge[i].push_back(x);
    edge[x].push_back(i);
  }
  init_LCA();
  int m;
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d %d", &u, &v);
    end_path[u].push_back(v);
    end_path[v].push_back(u);
    int t = LCA(u, v);
    go[u] = max(go[u], dep[u] - dep[t]);
    go[v] = max(go[v], dep[v] - dep[t]);
  }
  init_jump();
  int q;
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    if (lb[u] > lb[v]) swap(u, v);
    int t = LCA(u, v);
    if (t == u || t == v) {
      if (u == v)
        ans[i] = 0;
      else
        ans[i] = JUMP(u, v, dep[t]) + 1;
    } else {
      ans[i] = JUMP(u, v, dep[t]) + 2;
      query_pair[eu].emplace_back(i, ev);
    }
  }
  solve(1, 0);
  for (int i = 1; i <= q; i++) {
    printf("%d\n", max(-1, ans[i]));
  }
}