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 <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
#define dingyi int mid = l + r >> 1, ls = p << 1, rs = p << 1 | 1
#define y0 y_csyakioi_0
#define y1 y_csyakioi_1
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define per(i, x, y) for(int i = x; i >= y; --i)
#define repg(i, u) for(int i = head[u]; i; i = e[i].nxt)
inline int read(){
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9'){ if(ch == '-') f = -1; ch = getchar(); }
	while(ch >= '0' && ch <= '9'){ x = x * 10 + (ch ^ 48); ch = getchar(); }
	return x * f;
}
const int N = 300010;
struct edge{ int v, nxt; }e[N << 1]; struct pat{ int x, y, z, a, b; }q[N];
int head[N], cnt, n, m, x, y, z, L[N], R[N], tot, num, f[N][20], g[N << 2], c[N], dep[N];
inline void add(int u, int v){ e[++cnt].v = v; e[cnt].nxt = head[u]; head[u] = cnt; }
inline void dfs(int u, int fa){
	f[u][0] = fa; L[u] = ++tot; dep[u] = dep[fa] + 1;
	rep(i, 1, 19) f[u][i] = f[f[u][i - 1]][i - 1];
	repg(i, u) if(e[i].v != fa) dfs(e[i].v, u); R[u] = tot;
}
inline int lca(int x, int y){
	if(dep[x] < dep[y]) swap(x, y); per(i, 19, 0) if(dep[f[x][i]] >= dep[y]) x = f[x][i];
	if(x == y) return x; per(i, 19, 0) if(f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
	return f[x][0];
}
inline int lb(int x){ return x & -x; }
inline void change(int x, int y){ for(; x <= n; x += lb(x)) c[x] += y; }
inline int query(int x){ int ans = 0; for(; x; x -= lb(x)) ans += c[x]; return ans; }
inline int Query(int l, int r){ return query(r) - query(l - 1); }
inline int anc(int x, int y){ if(x == y) return ++num; per(i, 19, 0) if(dep[f[x][i]] > dep[y]) x = f[x][i]; return x; }
inline bool cmp(pat x, pat y){ return dep[x.z] ^ dep[y.z] ? dep[x.z] < dep[y.z] : x.z ^ y.z ? x.z < y.z : x.a ^ y.a ? x.a > y.a : x.b > y.b; }
inline void mian(){
	num = n = read(); rep(i, 1, n - 1) x = read(), y = read(), add(x, y), add(y, x); dfs(1, 0);
	m = read(); rep(i, 1, m){
		x = q[i].x = read(); y = q[i].y = read(); z = q[i].z = lca(x, y); q[i].a = anc(x, z); q[i].b = anc(y, z);
		if(q[i].a > q[i].b) swap(q[i].x, q[i].y), swap(q[i].a, q[i].b);
	}
	sort(q + 1, q + m + 1, cmp); ll ans = 0;
	rep(i, 1, m){
		int j = i; for(; j < m && q[j + 1].z == q[i].z; ++j); int sum = 0;
		rep(k, i, j){
			int l = k; for(; l < j && q[l + 1].a == q[k].a; ++l);
			rep(p, k, l) ans += sum - g[q[p].b];
			rep(p, k, l) ++g[q[p].a], ++g[q[p].b];
			sum += l - k + 1; k = l;
		}
		rep(k, i, j) g[q[k].a] = g[q[k].b] = 0;
		rep(k, i, j){
			ans += Query(L[q[k].z], R[q[k].z]);
			if(q[k].a <= n) ans -= Query(L[q[k].a], R[q[k].a]);
			if(q[k].b <= n) ans -= Query(L[q[k].b], R[q[k].b]);
		}
		rep(k, i, j) change(L[q[k].x], 1), change(L[q[k].y], 1); i = j;
	}
	printf("%lld", ans);
}
int main(){ int qwq = 1; while(qwq--) mian(); return 0; }