#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int K = 100;
const int LOG = 20;
int n, m, q, tick;
int st[N], nd[N], dep[N], lca[LOG][N];
vector<int> v[N], p[N];
vector<pair<int, int> > qq[N];
int ans[N];
int get(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = LOG - 1; i >= 0; i--)
    if (dep[x] - (1 << i) >= dep[y]) x = lca[i][x];
  if (x == y) return x;
  for (int i = LOG - 1; i >= 0; i--)
    if (lca[i][x] != lca[i][y]) x = lca[i][x], y = lca[i][y];
  return lca[0][x];
}
void dfs(int p, int x) {
  lca[0][x] = p;
  for (int i = 1; i < LOG; i++) lca[i][x] = lca[i - 1][lca[i - 1][x]];
  dep[x] = dep[p] + 1;
  st[x] = ++tick;
  for (auto u : v[x]) {
    if (u != p) {
      dfs(x, u);
    }
  }
  nd[x] = tick;
}
int go[N];
int best(int x, int y) {
  if (dep[x] < dep[y]) return x;
  return y;
}
int inside(int x, int y) { return st[y] <= st[x] and nd[x] <= nd[y]; }
int upNode[N], upCost[N];
void dfs2(int pr, int x) {
  go[x] = x;
  for (auto u : p[x]) go[x] = best(go[x], u);
  for (auto u : v[x]) {
    if (u != pr) {
      dfs2(x, u);
      go[x] = best(go[x], go[u]);
    }
  }
  int y = go[x];
  int needDist = min(K, dep[x]);
  int cnt = y != x;
  while (dep[x] - dep[y] < needDist and y != go[y]) {
    cnt++;
    y = go[y];
  }
  if (dep[x] - dep[y] >= needDist) {
    upNode[x] = y;
    upCost[x] = cnt;
  }
}
set<int> s[N];
void dfs3(int pr, int x) {
  for (auto u : v[x]) {
    if (u != pr) {
      dfs3(x, u);
      if (s[x].size() < s[u].size()) swap(s[x], s[u]);
      for (auto v : s[u]) s[x].insert(v);
    }
  }
  for (auto tmp : qq[x]) {
    int y = tmp.first;
    int i = tmp.second;
    auto it = s[x].lower_bound(st[y]);
    if (it != s[x].end() and *it <= nd[y]) ans[i]--;
  }
}
int main() {
  scanf("%d", &n);
  for (int x = 2; x <= n; x++) {
    int y;
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int c = get(x, y);
    p[x].push_back(c);
    p[y].push_back(c);
    s[x].insert(st[y]);
    s[y].insert(st[x]);
  }
  dfs2(0, 1);
  scanf("%d", &q);
  for (int i = 1; i <= q; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    int c = get(x, y);
    int res = 0;
    auto climb = [&](int &x) {
      while (dep[x] - dep[c] > K and !inside(c, go[x])) {
        if (!upNode[x]) {
          res = -1;
          break;
        }
        res += upCost[x];
        x = upNode[x];
      }
      while (!inside(c, go[x])) {
        if (go[x] == x) {
          res = -1;
          break;
        }
        res++;
        x = go[x];
      }
    };
    climb(x);
    if (res == -1) {
      ans[i] = -1;
      continue;
    }
    climb(y);
    if (res == -1) {
      ans[i] = -1;
      continue;
    }
    if (inside(x, y) or inside(y, x)) {
      ans[i] = res + 1;
    } else {
      ans[i] = res + 2;
      qq[x].push_back({y, i});
    }
  }
  dfs3(0, 1);
  for (int i = 1; i <= q; i++) printf("%d\n", ans[i]);
  return 0;
}
