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 inf = 1e9 + 9;
const long long int MOD = 1e9 + 696969;
mt19937_64 rng(time(0));
int random(int l, int r) { return uniform_int_distribution<int>(l, r)(rng); }
const long long INF = 1e18;
const int maxn = 200100;
int bridge[maxn];
const int LOG = 19;
vector<int> v[maxn];
int skok[LOG][maxn];
int most_skok[LOG][maxn];
int d[maxn];
int par[maxn];
int pre[maxn], maxpre[maxn];
int DL;
vector<pair<int, pair<int, int> > > bridges[maxn];
void dfs(int x) {
  pre[x] = ++DL;
  maxpre[x] = pre[x];
  for (auto &u : v[x]) {
    d[u] = d[x] + 1;
    skok[0][u] = x;
    dfs(u);
    maxpre[x] = max(maxpre[x], maxpre[u]);
  }
}
int make_jump(int x, int k) {
  for (int j = 0; j < LOG; ++j) {
    if (k & (1 << j)) x = skok[j][x];
  }
  return x;
}
int getLCA(int x, int y) {
  if (d[x] < d[y])
    y = make_jump(y, d[y] - d[x]);
  else
    x = make_jump(x, d[x] - d[y]);
  for (int j = LOG - 1; j >= 0; --j) {
    if (skok[j][x] != skok[j][y]) {
      x = skok[j][x];
      y = skok[j][y];
    }
  }
  if (x == y) return x;
  return skok[0][x];
}
void przypisz_mosty(int x) {
  for (auto &most : bridges[x]) {
    int node = most.second.first;
    while (node != x && bridge[node] == 0) {
      bridge[node] = most.second.second;
      most_skok[0][node] = x;
      node = par[node];
    }
  }
  for (auto &u : v[x]) przypisz_mosty(u);
}
int ans[maxn];
int jump_cost[maxn];
vector<pair<pair<int, int>, pair<int, int> > > rect_queries[maxn];
vector<int> points[maxn];
int rect_points[maxn];
int dr[maxn];
inline void add(int p, int val) {
  for (; p < maxn; p += p & (-p)) dr[p] += val;
}
inline int get(int p) {
  int res = 0;
  for (; p > 0; p -= p & (-p)) res += dr[p];
  return res;
}
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  };
  int n, m, zap;
  cin >> n;
  for (int i = (2); i <= (n); ++i) {
    int p;
    cin >> p;
    v[p].push_back(i);
    par[i] = p;
  }
  par[1] = 1;
  dfs(1);
  skok[0][1] = 1;
  for (int j = 1; j < (LOG); ++j) {
    for (int i = (1); i <= (n); ++i) skok[j][i] = skok[j - 1][skok[j - 1][i]];
  }
  cin >> m;
  for (int i = (1); i <= (m); ++i) {
    int a, b;
    cin >> a >> b;
    int u = getLCA(a, b);
    0 && cerr;
    bridges[u].push_back({d[b], {b, i}});
    bridges[u].push_back({d[a], {a, i}});
    if (u != a && u != b) {
      points[pre[a]].push_back(pre[b]);
      points[pre[b]].push_back(pre[a]);
    }
  }
  for (int i = (1); i <= (n); ++i) sort(begin(bridges[i]), end(bridges[i]));
  przypisz_mosty(1);
  for (int i = (1); i <= (n); ++i) {
    if (most_skok[0][i] == 0) most_skok[0][i] = i;
  }
  for (int j = 1; j < (LOG); ++j) {
    for (int i = (1); i <= (n); ++i)
      most_skok[j][i] = most_skok[j - 1][most_skok[j - 1][i]];
  }
  cin >> zap;
  for (int z = (1); z <= (zap); ++z) {
    int a, b;
    cin >> a >> b;
    int u = getLCA(a, b);
    if (d[most_skok[LOG - 1][a]] > d[u])
      ans[z] = inf;
    else if (d[most_skok[LOG - 1][b]] > d[u])
      ans[z] = inf;
    else {
      int cost = 0;
      for (int j = LOG - 1; j >= 0; --j) {
        int g1 = most_skok[j][a], g2 = most_skok[j][b];
        if (d[g1] > d[u]) {
          cost += (1 << j);
          a = most_skok[j][a];
        }
        if (d[g2] > d[u]) {
          cost += (1 << j);
          b = most_skok[j][b];
        }
      }
      jump_cost[z] = cost;
      assert(d[most_skok[0][a]] <= d[u]);
      assert(d[most_skok[0][b]] <= d[u]);
      if (a == u || b == u) {
        rect_points[z] = 1;
      } else {
        pair<int, int> inter = {pre[a], maxpre[a]};
        pair<int, int> i2 = {pre[b], maxpre[b]};
        rect_queries[inter.second].push_back({i2, {z, 1}});
        rect_queries[inter.first - 1].push_back({i2, {z, -1}});
      }
    }
  }
  for (int coord = (0); coord <= (n); ++coord) {
    for (auto &c : points[coord]) add(c, 1);
    for (auto &query : rect_queries[coord]) {
      int a = query.first.first, b = query.first.second;
      int score = get(b) - get(a - 1);
      rect_points[query.second.first] += score * query.second.second;
    }
  }
  for (int i = (1); i <= (zap); ++i) {
    if (ans[i] > n) {
      cout << "-1\n";
    } else {
      if (rect_points[i] > 0)
        cout << 1 + jump_cost[i] << "\n";
      else
        cout << 2 + jump_cost[i] << "\n";
    }
  }
}