You are given a tree consisting of n vertices, and m simple vertex paths. Your task is to find how many pairs of those paths intersect at exactly one vertex. More formally you have to find the number of pairs (i, j) (1 ≤ i < j ≤ m) such that path_i and path_j have exactly one vertex in common. 

Input

First line contains a single integer n (1 ≤ n ≤ 3 ⋅ 10^5).

Next n - 1 lines describe the tree. Each line contains two integers u and v (1 ≤ u, v ≤ n) describing an edge between vertices u and v.

Next line contains a single integer m (1 ≤ m ≤ 3 ⋅ 10^5).

Next m lines describe paths. Each line describes a path by it's two endpoints u and v (1 ≤ u, v ≤ n). The given path is all the vertices on the shortest path from u to v (including u and v).

Output

Output a single integer — the number of pairs of paths that intersect at exactly one vertex.

Examples

Input


5
1 2
1 3
1 4
3 5
4
2 3
2 4
3 4
3 5


Output


2


Input


1
3
1 1
1 1
1 1


Output


3


Input


5
1 2
1 3
1 4
3 5
6
2 3
2 4
3 4
3 5
1 1
1 2


Output


7

Note

<image>

The tree in the first example and paths look like this. Pairs (1,4) and (3,4) intersect at one vertex.

In the second example all three paths contain the same single vertex, so all pairs (1, 2), (1, 3) and (2, 3) intersect at one vertex.

The third example is the same as the first example with two additional paths. Pairs (1,4), (1,5), (2,5), (3,4), (3,5), (3,6) and (5,6) intersect at one vertex.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

const int maxn = 312345;

int n, m;
int dep[maxn], anc[maxn][19], nex[maxn], f[maxn];
vector<int> G[maxn], query[maxn];
vector<pii> claws[maxn];
ll ans;

void dfs(int u, int par) {
  dep[u] = dep[par] + 1;
  anc[u][0] = par;
  FOR(i, 1, 18) anc[u][i] = anc[anc[u][i - 1]][i - 1];
  for (auto v : G[u]) if (v != par) dfs(v, u);
}

int lift(int u, int d) {
  ROF(i, 18, 0) if (d >= (1 << i)) {
    u = anc[u][i];
    d -= 1 << i;
  }
  return u;
}

int lca(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  ROF(i, 18, 0) if (dep[u] <= dep[anc[v][i]]) v = anc[v][i];
  if (u == v) return u;
  ROF(i, 18, 0) if (anc[u][i] != anc[v][i]) u = anc[u][i], v = anc[v][i];
  return anc[u][0];
}

void dfs2(int u, int par) {
  map<int, int> cnt1;
  map<pii, int> cnt2;
  for (auto &[x, y] : claws[u]) {
    if (x > y) swap(x, y);
    cnt1[x]++, cnt1[y]++;
    cnt2[mp(x, y)]++;
  }
  for (auto [x, y] : claws[u]) {
    ans += claws[u].size() - 1;
    ans -= cnt1[x] - 1 + cnt1[y] - 1;
    ans += cnt2[mp(x, y)] - 1;
  }
  for (auto v : G[u]) if (v != par) dfs2(v, u);
}

void dfs3(int u, int par) {
  for (auto v : G[u]) if (v != par) {
    dfs3(v, u);
    f[u] += f[v];
  }
  for (auto v : query[u]) if (v != u) f[lift(v, dep[v] - dep[u] - 1)]--;
  ans += ll(claws[u].size()) * f[u];
  for (auto [x, y] : claws[u]) {
    if (x <= n) ans -= f[x];
    if (y <= n) ans -= f[y];
  }
}

int main() {
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cin >> n;
  REP(i, n - 1) {
    int u, v;
    cin >> u >> v;
    G[u].eb(v);
    G[v].eb(u);
  }
  dfs(1, 0);
  FOR(i, 1, n) nex[i] = n;
  cin >> m;
  while (m--) {
    int u, v;
    cin >> u >> v;
    int a = lca(u, v);
    int au = a == u ? ++nex[u] : lift(u, dep[u] - dep[a] - 1);
    int av = a == v ? ++nex[v] : lift(v, dep[v] - dep[a] - 1);
    f[u]++, f[v]++;
    f[a] -= 2;
    claws[a].eb(au, av);
    query[a].eb(u); query[a].eb(v);
  }
  dfs2(1, 0);
  ans /= 2;
  dfs3(1, 0);
  cout << ans;
}
