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 + 1;
const int L = 18;
template <class T>
struct fenwick_tree {
  T tree[N];
  void update(int a, T val) {
    for (; a < N; a += a & -a) {
      tree[a] += val;
    }
  }
  T query(int a) {
    T res = 0;
    for (; a; a -= a & -a) {
      res += tree[a];
    }
    return res;
  }
  T query(int a, int b) { return query(b) - query(a - 1); }
};
vector<array<int, 2>> queries[N];
fenwick_tree<int> ft;
vector<int> buses[N];
int ans[N];
vector<int> adj[N];
int par[L][N];
int nxt[L][N];
int time_out[N];
int time_in[N];
int dep[N];
int timer;
int log_n;
int n;
bool ancestor(int u, int v) {
  return time_in[u] <= time_in[v] && time_out[u] >= time_out[v];
}
int lca(int u, int v) {
  if (ancestor(u, v)) {
    return u;
  }
  for (int i = log_n - 1; i >= 0; --i) {
    if (!ancestor(par[i][u], v)) {
      u = par[i][u];
    }
  }
  return par[0][u];
}
int process(int& u, int l) {
  int res = 0;
  for (int i = log_n - 1; i >= 0; --i) {
    if (!ancestor(nxt[i][u], l)) {
      u = nxt[i][u];
      res += 1 << i;
    }
  }
  return res + 1;
}
void dfs(int u) {
  time_in[u] = ++timer;
  for (int c : adj[u]) {
    dep[c] = dep[u] + 1;
    par[0][c] = u;
    dfs(c);
  }
  time_out[u] = timer;
}
void dfs_pull(int u) {
  for (int c : adj[u]) {
    dfs_pull(c);
    if (dep[nxt[0][u]] > dep[nxt[0][c]]) {
      nxt[0][u] = nxt[0][c];
    }
  }
}
void dfs_calc(int u) {
  vector<int> pre(queries[u].size());
  for (int i = 0; i < int(queries[u].size()); ++i) {
    int v = queries[u][i][0];
    pre[i] = ft.query(time_in[v], time_out[v]);
  }
  for (int v : buses[u]) {
    ft.update(time_in[v], 1);
  }
  for (int c : adj[u]) {
    dfs_calc(c);
  }
  for (int i = 0; i < int(queries[u].size()); ++i) {
    int v = queries[u][i][0];
    if (ft.query(time_in[v], time_out[v]) > pre[i]) {
      --ans[queries[u][i][1]];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  while ((1 << log_n) <= n) {
    ++log_n;
  }
  for (int i = 2; i <= n; ++i) {
    int p;
    cin >> p;
    adj[p].push_back(i);
  }
  dfs(1);
  time_out[0] = timer;
  for (int i = 1; i < log_n; ++i) {
    for (int j = 1; j <= n; ++j) {
      par[i][j] = par[i - 1][par[i - 1][j]];
    }
  }
  iota(nxt[0] + 1, nxt[0] + n + 1, 1);
  int m;
  cin >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    if (time_in[u] > time_in[v]) {
      swap(u, v);
    }
    buses[u].push_back(v);
    int l = lca(u, v);
    for (int i : {u, v}) {
      if (dep[nxt[0][i]] > dep[l]) {
        nxt[0][i] = l;
      }
    }
  }
  dfs_pull(1);
  for (int i = 1; i < log_n; ++i) {
    for (int j = 1; j <= n; ++j) {
      nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; ++i) {
    int u, v;
    cin >> u >> v;
    if (time_in[u] > time_in[v]) {
      swap(u, v);
    }
    if (ancestor(u, v)) {
      ans[i] = process(v, u);
    } else {
      int l = lca(u, v);
      ans[i] += process(u, l) + process(v, l);
      assert(time_in[u] < time_in[v]);
      queries[u].push_back({v, i});
    }
  }
  dfs_calc(1);
  for (int i = 0; i < q; ++i) {
    cout << (ans[i] < n ? ans[i] : -1) << "\n";
  }
}