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 maxn = 2e5 + 79, logn = 19;
int n, m, q, timer = 0;
vector<vector<int> > low(logn, vector<int>(maxn, 0)),
    l(logn, vector<int>(maxn, 0)), s(maxn), myq(maxn);
vector<vector<pair<int, int> > > v(maxn);
vector<int> d(maxn, 0), ans(maxn, 1), tin(maxn, 0), tout(maxn, 0), f(maxn, 0),
    tmpq(maxn, 0);
vector<pair<int, int> > qu(maxn);
int lca(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  for (int i = logn - 1; i >= 0; i--)
    if (d[l[i][u]] >= d[v]) u = l[i][u];
  if (u == v) return u;
  for (int i = logn - 1; i >= 0; i--)
    if (l[i][u] != l[i][v]) u = l[i][u], v = l[i][v];
  return l[0][u];
}
void dfs_d(int vr = 0) {
  for (int i : s[vr]) {
    d[i] = d[vr] + 1;
    dfs_d(i);
  }
}
void dfs_low(int vr = 0) {
  low[0][vr] = vr;
  tin[vr] = timer++;
  for (pair<int, int> i : v[vr])
    low[0][vr] = min(make_pair(d[low[0][vr]], low[0][vr]),
                     make_pair(d[i.first], i.first))
                     .second;
  for (int i : s[vr]) {
    dfs_low(i);
    low[0][vr] = min(make_pair(d[low[0][vr]], low[0][vr]),
                     make_pair(d[low[0][i]], low[0][i]))
                     .second;
  }
  tout[vr] = timer;
}
void add(int i, int d) {
  for (; i < maxn; i = (i | (i + 1))) f[i] += d;
}
int sum(int i) {
  int ans = 0;
  for (; i >= 0; i = (i & (i + 1)) - 1) ans += f[i];
  return ans;
}
void dfs_ans(int vr = 0) {
  for (int i : myq[vr])
    tmpq[i] = sum(tout[qu[i].second]) - sum(tin[qu[i].second]);
  for (pair<int, int> i : v[vr]) add(tin[i.second] + 1, 1);
  for (int i : s[vr]) dfs_ans(i);
  for (int i : myq[vr])
    if (tmpq[i] != sum(tout[qu[i].second]) - sum(tin[qu[i].second])) ans[i]--;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> l[0][i];
    s[--l[0][i]].push_back(i);
  }
  for (int j = 1; j < logn; j++)
    for (int i = 0; i < n; i++) l[j][i] = l[j - 1][l[j - 1][i]];
  cin >> m;
  dfs_d();
  for (int i = 0, a, b; i < m; i++) {
    cin >> a >> b;
    int l = lca(--a, --b);
    v[a].push_back({l, b});
    v[b].push_back({l, a});
  }
  dfs_low();
  for (int j = 1; j < logn; j++)
    for (int i = 0; i < n; i++) low[j][i] = low[j - 1][low[j - 1][i]];
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> qu[i].first >> qu[i].second;
    --qu[i].first;
    --qu[i].second;
    int li = lca(qu[i].first, qu[i].second);
    for (int j = logn - 1; j >= 0; j--) {
      if (d[low[j][qu[i].first]] > d[li]) {
        qu[i].first = low[j][qu[i].first];
        ans[i] += (1 << j);
      }
      if (d[low[j][qu[i].second]] > d[li]) {
        qu[i].second = low[j][qu[i].second];
        ans[i] += (1 << j);
      }
    }
    if (d[low[0][qu[i].first]] > d[li] || d[low[0][qu[i].second]] > d[li]) {
      ans[i] = -1;
      continue;
    }
    if (qu[i].first == li || qu[i].second == li) continue;
    ans[i]++;
    myq[qu[i].first].push_back(i);
  }
  dfs_ans();
  for (int i = 0; i < q; i++) cout << ans[i] << "\n";
  return 0;
}