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. 
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const int INF = (int)(1e9 + 1e5);
const long long LINF = (long long)(1e18);
const long long MX = 100500;
const double EPS = 1e-9;
const int MOD = 1000000007;
int tnum;
const int MAXN = 200500;
const int LOG = 25;
int n, m, k;
vector<vector<int>> g;
vector<vector<int>> pa;
vector<vector<int>> ro;
int tin[MAXN], tout[MAXN], timer;
int ans[MAXN];
pair<int, int> r[MAXN];
pair<int, int> qu[MAXN];
int p[MAXN][LOG];
int h[MAXN];
int mx[MAXN][LOG];
int lca_r[MAXN], lca_q[MAXN];
int tre[MAXN << 2];
pair<int, int> ch[MAXN];
int prev_sum[MAXN];
void init() {
  scanf("%d", &n);
  g.resize(n + 1);
  for (int i = 2; i <= n; ++i) {
    int q;
    scanf("%d", &q);
    g[q].push_back(i);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &r[i].first, &r[i].second);
  }
  scanf("%d", &k);
  for (int i = 1; i <= k; ++i) {
    scanf("%d%d", &qu[i].first, &qu[i].second);
  }
}
int get_sum(int tv, int tl, int tr, int l, int r) {
  if (l > r) {
    return 0;
  }
  if (tl == l && r == tr) {
    return tre[tv];
  }
  int tm = (tl + tr) >> 1;
  return get_sum(tv * 2, tl, tm, l, min(tm, r)) +
         get_sum(tv * 2 + 1, tm + 1, tr, max(l, tm + 1), r);
}
void add(int tv, int tl, int tr, int pos) {
  ++tre[tv];
  if (tl < tr) {
    int tm = (tl + tr) >> 1;
    if (pos <= tm) {
      add(tv * 2, tl, tm, pos);
    } else {
      add(tv * 2 + 1, tm + 1, tr, pos);
    }
  }
}
void dfs_init(int v, int par) {
  p[v][0] = par;
  h[v] = h[par] + 1;
  for (int i = 1; (1 << i) < h[v]; ++i) {
    p[v][i] = p[p[v][i - 1]][i - 1];
  }
  tin[v] = tout[v] = ++timer;
  mx[v][0] = v;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    dfs_init(to, v);
    tout[v] = tout[to];
  }
}
void update_mx(int v, int cand) {
  if (h[cand] < h[mx[v][0]]) {
    mx[v][0] = cand;
  }
}
void dfs_calc_mx(int v) {
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    dfs_calc_mx(to);
    update_mx(v, mx[to][0]);
  }
}
void dfs_calc_routes(int v) {
  for (int i = 1; i < LOG; ++i) {
    mx[v][i] = mx[mx[v][i - 1]][i - 1];
  }
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    dfs_calc_routes(to);
  }
}
bool is_parent(int p, int v) { return tin[p] <= tin[v] && tout[v] <= tout[p]; }
int get_lca(int a, int b) {
  if (is_parent(a, b)) {
    return a;
  }
  for (int i = LOG - 1; i >= 0; --i) {
    if (p[a][i] && !is_parent(p[a][i], b)) {
      a = p[a][i];
    }
  }
  return p[a][0];
}
int get_cnt(int v, int p) {
  if (v == p) {
    return 0;
  }
  if (h[mx[v][LOG - 1]] > h[p]) {
    return -1;
  }
  int res = 0;
  for (int i = LOG - 1; i >= 0; --i) {
    int cur = mx[v][i];
    if (h[cur] > h[p]) {
      v = cur;
      res += (1 << i);
    }
  }
  return ++res;
}
int get_vertex(int v, int cnt) {
  if (cnt == -1) {
    return v;
  }
  for (int i = 0; i < LOG; ++i) {
    if (cnt & (1 << i)) {
      v = mx[v][i];
    }
  }
  return v;
}
void dfs_check(int v) {
  for (int i = 0; i < pa[v].size(); ++i) {
    int num = pa[v][i];
    prev_sum[num] = get_sum(1, 1, n, tin[ch[num].second], tout[ch[num].second]);
  }
  for (int i = 0; i < ro[v].size(); ++i) {
    add(1, 1, n, tin[ro[v][i]]);
  }
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    dfs_check(to);
  }
  for (int i = 0; i < pa[v].size(); ++i) {
    int num = pa[v][i];
    auto cur_sum = get_sum(1, 1, n, tin[ch[num].second], tout[ch[num].second]);
    if (cur_sum != prev_sum[num]) {
      --ans[num];
    }
  }
}
void solve() {
  dfs_init(1, 0);
  ro.resize(n + 1);
  for (int i = 1; i <= m; ++i) {
    if (tin[r[i].first] > tin[r[i].second]) {
      swap(r[i].first, r[i].second);
    }
    lca_r[i] = get_lca(r[i].first, r[i].second);
    update_mx(r[i].first, lca_r[i]);
    update_mx(r[i].second, lca_r[i]);
    ro[r[i].first].push_back(r[i].second);
  }
  dfs_calc_mx(1);
  dfs_calc_routes(1);
  pa.resize(n + 1);
  for (int i = 1; i <= k; ++i) {
    if (tin[qu[i].first] > tin[qu[i].second]) {
      swap(qu[i].first, qu[i].second);
    }
    lca_q[i] = get_lca(qu[i].first, qu[i].second);
    int cntl = get_cnt(qu[i].first, lca_q[i]);
    int cntr = get_cnt(qu[i].second, lca_q[i]);
    if (cntl == -1 || cntr == -1) {
      ans[i] = -1;
      continue;
    }
    ans[i] = cntl + cntr;
    if (qu[i].first != lca_q[i] && qu[i].second != lca_q[i]) {
      ch[i].first = get_vertex(qu[i].first, cntl - 1);
      ch[i].second = get_vertex(qu[i].second, cntr - 1);
      pa[ch[i].first].push_back(i);
    }
  }
  dfs_check(1);
}
void print_answer() {
  for (int i = 1; i <= k; ++i) {
    printf("%d\n", ans[i]);
  }
}
void precalc() {}
void run() {
  precalc();
  int t = 1;
  for (tnum = 1; tnum <= t; ++tnum) {
    init();
    solve();
    print_answer();
  }
}
int main() {
  srand(90);
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  run();
  return 0;
}
