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.
// Problem: F. Pairs of Paths
// Contest: Codeforces - Codeforces Round #703 (Div. 2)
// URL: https://codeforces.com/contest/1486/problem/F
// Memory Limit: 512 MB
// Time Limit: 6000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

template <typename Tp>
void read(Tp &res){
	static char ch; ch = getchar(), res = 0;
	static bool flag; flag = 0;
	while(ch < '0' || ch > '9') flag = (ch == '-'), ch = getchar();
	while(ch >= '0' && ch <= '9') res = res * 10 + ch - 48, ch = getchar();
	if(flag) res = -res;
}

void read(char *s){
	static char ch; ch = getchar();
	while(ch < 'a' || ch > 'z') ch = getchar();
	while(ch >= 'a' && ch <= 'z') *(s++) = ch, ch = getchar();
	*s = '\0';
}

const int maxn = 3e5 + 19;

struct Edge{
	int to, next;
}edge[maxn << 1];

int head[maxn], cnt;

inline void add(int from, int to){
	edge[++cnt].to = to;
	edge[cnt].next = head[from];
	head[from] = cnt;
}

int top[maxn], son[maxn], dep[maxn], size[maxn], dfn[maxn], ind, fa[maxn];

void dfs1(int node, int f){
	fa[node] = f, dep[node] = dep[f] + 1, size[node] = 1;
	for(int i = head[node]; i; i = edge[i].next)
		if(edge[i].to != f){
			dfs1(edge[i].to, node);
			size[node] += size[edge[i].to];
			if(size[edge[i].to] > size[son[node]]) son[node] = edge[i].to;
		}
}

void dfs2(int node, int f, int t){
	top[node] = t, dfn[node] = ++ind;
	if(son[node]) dfs2(son[node], node, t);
	for(int i = head[node]; i; i = edge[i].next)
		if(edge[i].to != f && edge[i].to != son[node])
			dfs2(edge[i].to, node, edge[i].to);
}

int lca(int x, int y){
	while(top[x] != top[y])
		if(dep[top[x]] > dep[top[y]]) x = fa[top[x]];
		else y = fa[top[y]];
	return dep[x] < dep[y] ? x : y;
}

int n, m, bra[maxn];
std::vector<std::pair<int, int>> gua[maxn], pa[maxn];
typedef long long ll;
ll ans;

struct BIT{
	int tr[maxn];
	void update(int x, int k){
		for(; x <= n; x += x & -x) tr[x] += k;
	}
	void modify(int l, int r){
		update(l, 1), update(r + 1, -1);
	}
	void dismodify(int l, int r){
		update(l, -1), update(r + 1, 1);
	}
	int query(int x){
		int res = 0;
		for(; x; x -= x & -x) res += tr[x];
		return res;
	}
}t1, t2;

void modify(int x, int y){
	while(top[x] != top[y])
		if(dep[top[x]] > dep[top[y]])
			t1.modify(dfn[top[x]], dfn[x]), t2.modify(dfn[top[x]], dfn[x]), x = fa[top[x]];
		else
			t1.modify(dfn[top[y]], dfn[y]), t2.modify(dfn[top[y]], dfn[y]), y = fa[top[y]];
	if(dep[x] > dep[y]) std::swap(x, y);
	if(x != y) t2.modify(dfn[x] + 1, dfn[y]);
	t1.modify(dfn[x], dfn[y]);
}

void dismodify(int x, int y){
	while(top[x] != top[y])
		if(dep[top[x]] > dep[top[y]])
			t1.dismodify(dfn[top[x]], dfn[x]), t2.dismodify(dfn[top[x]], dfn[x]), x = fa[top[x]];
		else
			t1.dismodify(dfn[top[y]], dfn[y]), t2.dismodify(dfn[top[y]], dfn[y]), y = fa[top[y]];
	if(dep[x] > dep[y]) std::swap(x, y);
	if(x != y) t2.dismodify(dfn[x] + 1, dfn[y]);
	t1.dismodify(dfn[x], dfn[y]);
}

int main(){
	read(n);
	for(int i = 2, x, y; i <= n; ++i)
		read(x), read(y), add(x, y), add(y, x);
	dfs1(1, 0), dfs2(1, 0, 1);
	read(m);
	for(int i = 1, x, y, p; i <= m; ++i){
		read(x), read(y), p = lca(x, y), pa[p].emplace_back(x, y);
		modify(x, y);
		if(x != p){
			if(top[x] != top[p]){
				while(top[fa[top[x]]] != top[p]) x = fa[top[x]];
				x = top[x];
				if(fa[x] != p) x = son[p];
			}
			else x = son[p];
		}
		else x = 0;
		std::swap(x, y);
		if(x != p){
			if(top[x] != top[p]){
				while(top[fa[top[x]]] != top[p]) x = fa[top[x]];
				x = top[x];
				if(fa[x] != p) x = son[p];
			}
			else x = son[p];
		}
		else x = 0;
		if(x > y) std::swap(x, y);
		gua[p].emplace_back(x, y);
	}
	for(int node = 1; node <= n; ++node){
		std::sort(gua[node].begin(), gua[node].end());
//		printf("for node %d:\n", node);
		for(int i = 0; i < (int)pa[node].size(); ++i) dismodify(pa[node][i].first, pa[node][i].second);
		for(int i = 0; i < (int)gua[node].size(); ++i){
			int x = gua[node][i].first, y = gua[node][i].second;
			ll res = t1.query(dfn[node]);
			if(x) res -= t2.query(dfn[x]);
			if(y) res -= t2.query(dfn[y]);
//			printf("%d %d %lld\n", x, y, res);
			ans += res;
		}
		ll res = 0ll;
		for(int i = 0; i < (int)gua[node].size(); ++i)
			++bra[gua[node][i].first], ++bra[gua[node][i].second];
		for(int i = 0; i < (int)gua[node].size(); ++i){
			int l = i, r = i;
			while(r + 1 < (int)gua[node].size() && gua[node][r + 1] == gua[node][r]) ++r;
			ll tmp = gua[node].size() - 1;
			int x = gua[node][r].first, y = gua[node][r].second;
			if(x) tmp -= bra[x] - 1;
			if(y) tmp -= bra[y] - 1;
			if(x && y) tmp += r - l;
			i = r;
			res += tmp * (r - l + 1);
		}
		ans += res >> 1;
		for(int i = 0; i < (int)gua[node].size(); ++i)
			--bra[gua[node][i].first], --bra[gua[node][i].second];
		for(int i = 0; i < (int)pa[node].size(); ++i) modify(pa[node][i].first, pa[node][i].second);
	}
	printf("%lld\n", ans);
}