#include<bits/stdc++.h>
#define PR(a,b) make_pair(a,b)
using namespace std;
const int maxn=3e5+5;
const int maxk=22;
const int maxm=6e5+5;
typedef long long LL;
int n,m;
int A[maxn],B[maxn],C[maxn];

int tot;
int h[maxn],last[maxm],to[maxm];

int dep[maxn],fa[maxn][maxk];

int suma[maxn],sumb[maxn],sumc[maxn],sumd[maxn],pas[maxn];

LL ans1,ans2,ans3;

map<pair<int,int> ,int > mp;
void add_edge(int x,int y)
{
	to[++tot]=y,last[tot]=h[x],h[x]=tot;
}
void dfs(int x,int fr)
{
	for(int i=h[x];i;i=last[i]){
		int v=to[i];
		if(v==fr) continue;
		fa[v][0]=x;
		dep[v]=dep[x]+1;
		dfs(v,x);
	}
}
void pre_lca()
{
	for(int j=1;j<=20;++j)
	  for(int i=1;i<=n;++i)
	    fa[i][j]=fa[fa[i][j-1]][j-1];
}
int lca(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	int t=dep[x]-dep[y];
	for(int i=20;i>=0;--i)
	  if(((t>>i)&1)) x=fa[x][i];
	for(int i=20;i>=0;--i)
	  if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
	return x==y?x:fa[x][0];
}
int jump(int x,int y)
{
	if(x==y) return x;
	for(int i=20;i>=0;--i){
		int v=fa[x][i];
		if(dep[v]>dep[y]) x=fa[x][i];
	}
	return x;
}
void down(int x,int fr)
{
	for(int i=h[x];i;i=last[i]){
		int v=to[i];
		if(v==fr) continue;
		down(v,x);
		sumc[x]+=sumc[v];
	}
	sumb[x]=sumc[x]-suma[x];
	//cout<<"sum "<<x<<" "<<sumb[x]<<" "<<sumc[x]<<" "<<suma[x]<<endl;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n-1;++i){
		int a=0,b=0;
		scanf("%d%d",&a,&b);
		add_edge(a,b),add_edge(b,a);
	}
	dfs(1,0);
	pre_lca();
	scanf("%d",&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&A[i],&B[i]);
		if(A[i]>B[i]) swap(A[i],B[i]);
		C[i]=lca(A[i],B[i]);
		if(A[i]==B[i]){
			++sumd[A[i]];
			continue;
		}
		int t1=jump(A[i],C[i]),t2=jump(B[i],C[i]);
		if(A[i]!=C[i]&&B[i]!=C[i]){
			if(t1>t2) swap(t1,t2);
			++mp[PR(t1,t2)];
			++pas[t1],++pas[t2];
		}
		if(A[i]==C[i]||B[i]==C[i]){
			if(A[i]==C[i]) ++pas[t2];
			else ++pas[t1];
		}
		++sumc[A[i]],++sumc[B[i]],--sumc[C[i]],--sumc[fa[C[i]][0]];
		++suma[C[i]];
	}
	down(1,0);
	for(int i=1;i<=m;++i){
		if(A[i]==B[i]){
			ans1+=sumc[A[i]];
			continue;
		}
		if(A[i]!=C[i]&&B[i]!=C[i]){
			int t1=jump(A[i],C[i]),t2=jump(B[i],C[i]);
			if(t1>t2) swap(t1,t2);
			int t=sumc[C[i]]-(sumb[t1]+sumb[t2]-mp[PR(t1,t2)]);
			ans2+=t;
			ans3+=suma[C[i]]-pas[t1]-pas[t2]+mp[PR(t1,t2)];
			//cout<<"debug "<<i<<" "<<sumb[t1]<<" "<<sumb[t2]<<" "<<mp[PR(t1,t2)]<<endl;
		}
		else{
			int t1=0;
			if(A[i]==C[i]) t1=jump(B[i],C[i]);
			else t1=jump(A[i],C[i]);
			int t=sumc[C[i]]-sumb[t1];
			ans2+=t;
			ans3+=suma[C[i]]-pas[t1];
		}
	}
	for(int i=1;i<=n;++i)
	  ans1+=1LL*sumd[i]*(sumd[i]-1)/2;
	printf("%lld",ans1+ans2-ans3/2);
	return 0;
}