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 = 2 * 1000 * 100 + 10, LG = 20;
int n, par[N][LG], nxt[N][LG], h[N], st[N], en[N], TM;
vector<int> adj[N], vec[N], seg[N << 2];
void dfs(int v) {
  st[v] = TM++;
  for (auto u : adj[v]) {
    h[u] = h[v] + 1;
    dfs(u);
  }
  en[v] = TM;
}
int lca(int v, int u) {
  if (h[v] < h[u]) swap(v, u);
  for (int i = 0; i < LG; i++)
    if ((1 << i) & (h[v] - h[u])) v = par[v][i];
  if (v == u) return v;
  for (int i = LG - 1; i >= 0; i--)
    if (par[v][i] != par[u][i]) v = par[v][i], u = par[u][i];
  return par[v][0];
}
pair<int, int> ans(int v, int u) {
  int res = 0;
  for (int i = LG - 1; i >= 0; i--)
    if (h[u] < h[nxt[v][i]]) {
      v = nxt[v][i];
      res ^= 1 << i;
    }
  return {res, v};
}
void build(int l = 0, int r = n, int id = 1) {
  if (l + 1 == r) {
    seg[id] = vec[l];
    sort(seg[id].begin(), seg[id].end());
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, id << 1), build(mid, r, id << 1 | 1);
  merge(seg[id << 1].begin(), seg[id << 1].end(), seg[id << 1 | 1].begin(),
        seg[id << 1 | 1].end(), back_inserter(seg[id]));
}
bool get(int s, int e, int x, int y, int l = 0, int r = n, int id = 1) {
  if (s <= l && e >= r)
    return (bool)(lower_bound(seg[id].begin(), seg[id].end(), y) -
                  lower_bound(seg[id].begin(), seg[id].end(), x));
  if (s >= r || e <= l) return false;
  int mid = l + r >> 1;
  return (get(s, e, x, y, l, mid, id << 1) |
          get(s, e, x, y, mid, r, id << 1 | 1));
}
int query(int v, int u) {
  int w = lca(v, u);
  if (h[nxt[v][LG - 1]] > h[w] || h[nxt[u][LG - 1]] > h[w]) return -1;
  pair<int, int> a = ans(v, w);
  pair<int, int> b = ans(u, w);
  if (w == v || w == u ||
      get(st[a.second], en[a.second], st[b.second], en[b.second]))
    return a.first + b.first + 1;
  return a.first + b.first + 2;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> par[i][0];
    par[i][0]--;
    adj[par[i][0]].push_back(i);
    nxt[i][0] = i;
  }
  for (int i = 1; i < LG; i++)
    for (int v = 0; v < n; v++) par[v][i] = par[par[v][i - 1]][i - 1];
  dfs(0);
  int m;
  cin >> m;
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    a--, b--;
    int w = lca(a, b);
    for (auto v : {a, b})
      if (h[w] < h[nxt[v][0]]) nxt[v][0] = w;
    vec[st[a]].push_back(st[b]);
    vec[st[b]].push_back(st[a]);
  }
  build();
  for (int v = n - 1; v >= 0; v--)
    for (auto u : adj[v])
      if (h[nxt[v][0]] > h[nxt[u][0]]) nxt[v][0] = nxt[u][0];
  for (int i = 1; i < LG; i++)
    for (int v = 0; v < n; v++) nxt[v][i] = nxt[nxt[v][i - 1]][i - 1];
  int Q;
  cin >> Q;
  while (Q--) {
    int v, u;
    cin >> v >> u;
    --v, --u;
    cout << query(v, u) << '\n';
  }
  return 0;
}