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>
#define pr pair< int , int >
#define F first
#define S second
using namespace std;
int n , m , fa[20][330000] , dep[330000] , x , y;
int dfn[330000] , nfd[330000] , siz[330000] , hson[330000] , top[330000];
int fst[330000] , nex[660000] , v[660000] , tot;
long long s[330000] , c[1300000] , lazy[1300000] , d[330000] , ans , sum;
vector< pr > p[330000];
map< pr , long long > mp;
inline void add( int a , int b )
{
	nex[++tot] = fst[a]; fst[a] = tot;
	v[tot] = b;
}
void dfs1( int u , int f )
{
	fa[0][u] = f; dep[u] = dep[f] + 1; siz[u] = 1;
	for(int i = 1 ; i <= 18 ; i++ ) fa[i][u] = fa[i - 1][fa[i - 1][u]];
	for(int i = fst[u] ; i ; i = nex[i] )
	{
		if(v[i] == f) continue;
		dfs1(v[i] , u);
		siz[u] += siz[v[i]];
		if(siz[v[i]] > siz[hson[u]]) hson[u] = v[i];
	}
	return ;
}
void dfs2( int u , int t )
{
	dfn[u] = ++tot; nfd[tot] = u; top[u] = t;
	if(hson[u]) dfs2(hson[u] , t);
	for(int i = fst[u] ; i ; i = nex[i] )
	{
		if(v[i] == fa[0][u] || v[i] == hson[u]) continue;
		dfs2(v[i] , v[i]);
	}
	return ;
}
inline int lca( int a , int b )
{
	if(dep[a] < dep[b]) swap(a , b);
	for(int i = 18 ; i >= 0 ; i-- )
		if(dep[fa[i][a]] >= dep[b]) a = fa[i][a];
	if(a == b) return a;
	for(int i = 18 ; i >= 0 ; i-- )
		if(fa[i][a] != fa[i][b]) a = fa[i][a] , b = fa[i][b];
	return fa[0][a];
}
inline int las( int a , int b )
{
	if(a == b || a == -1 || b == -1) return -1;
	if(dep[a] > dep[b]) swap(a , b);
	for(int i = 18 ; i >= 0 ; i-- )
		if(dep[fa[i][b]] > dep[a]) b = fa[i][b];
	return b;
}
void Add( int l , int r , int id , int k )
{
    lazy[id] += k;
    c[id] += k * (r - l + 1);
    return ;
}
void push_down( int l , int r , int id )
{
    int mid = (l + r) >> 1;
    Add(l , mid , id << 1 , lazy[id]);
    Add(mid + 1 , r , id << 1 | 1, lazy[id]);
    lazy[id] = 0;
    return ;
}
void upd( int l , int r , int a , int b , int k , int id )
{
    if(l > b || r < a) return ;
    if(a <= l && r <= b)
    {
        Add(l , r , id , k);
        return ;
    }
    push_down(l , r , id);
    int mid = (l + r) >> 1;
    upd(l , mid , a , b , k , id << 1); upd(mid + 1 , r , a , b , k , id << 1 | 1);
    c[id] = c[id << 1] + c[id << 1 | 1];
    return ;
}
int ask( int l , int r , int a , int b , int id )
{
    if(l > b || r < a) return 0;
    if(a <= l && r <= b) return c[id];
    push_down(l , r , id);
    int mid = (l + r) >> 1;
    return ask(l , mid , a , b , id << 1) + ask(mid + 1 , r , a , b , id << 1 | 1);
}
void climb( int x , int y , int z )
{
	int fx = top[x] , fy = top[y];
	while(fx != fy)
	{
		if(dep[fx] > dep[fy])
		{
			upd(1 , n , dfn[fx] , dfn[x] , z , 1);
			x = fa[0][fx]; fx = top[x];
		}
		else
		{
			upd(1 , n , dfn[fy] , dfn[y] , z , 1);
			y = fa[0][fy]; fy = top[y];
		}
	}
    if(dep[x] > dep[y]) upd(1 , n , dfn[y] , dfn[x] , z , 1);
    else upd(1 , n , dfn[x] , dfn[y] , z , 1);
	return ;
}
int main()
{
	scanf("%d" , &n);
	for(int i = 1 ; i < n ; i++ )
	{
		scanf("%d%d" , &x , &y);
		add(x , y); add(y , x);
	}
	tot = 0;
	dfs1(1 , 1); dfs2(1 , 1); 
	scanf("%d" , &m);
	for(int i = 1 ; i <= m ; i++ )
	{
		scanf("%d%d" , &x , &y);
		int L = lca(x , y); int lx = las(L , x) , ly = las(L , y);
		if(lx > ly) swap(lx , ly) , swap(x , y);
		p[L].push_back(make_pair(x , y)); mp[make_pair(lx , ly)]++; 
		climb(x , y , 1); climb((~lx ? lx : x) , (~ly ? ly : y) , -1);
		if(~lx) s[lx]++; if(~ly) s[ly]++; if(L != x) d[x]++; if(L != y) d[y]++;
	}
	for(int i = 1 ; i <= n ; i++ ) //first
	{
		ans += (long long)p[i].size() * ((long long)p[i].size() - 1) / 2; sum = 0;
		for(int j = 0 ; j < p[i].size() ; j++ )
		{
			int lx = las(i , p[i][j].F) , ly = las(i , p[i][j].S);
			if(lx > ly) swap(lx , ly);
			if(lx == -1 && ~ly) sum += s[ly] - 1;
			if(~lx && ~ly) sum += s[lx] + s[ly] - mp[make_pair(lx , ly)] - 1;
		}
		ans -= sum / 2;
//		cerr << ans << ' ';
	}
//	cerr << endl;
//	cerr << ans << endl;
	for(int i = 1 ; i <= n ; i++ )  //second
	{
		for(int j = fst[i] ; j ; j = nex[j] )
		{
			if(v[j] == fa[0][i]) continue;
			long long cnt = ask(1 , n , dfn[v[j]] , dfn[v[j]] , 1);
			ans += cnt * ((long long)p[i].size() - s[v[j]]);
		}
		ans += d[i] * p[i].size();
	}
	printf("%lld" , ans);
    return 0;
}
/*

*/
