#include using namespace std; #define INF 1000000000 #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) typedef long long int LL; int parent[100002]; int rnk[100002]; vector v[100002]; int cost[100002]; bool check[100002]; bool check2[100002]; //親の作成 void dfs(int n,int x){ REP(i,v[n].size()){ int a=v[n][i]; if(check[a]==false){ check[a]=true; parent[a]=n; rnk[a]=x; dfs(a,x+1); } } } //imos法 LL imos(int n){ LL ans=0; REP(i,v[n].size()){ int a=v[n][i]; if(check2[a]==false){ check2[a]=true; ans+=imos(a); cost[n]+=cost[a]; } } LL mm=cost[n]; ans+=(mm+1)*mm/2; //cout<>N; REP(i,N-1){ int a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } check[1]=true; rnk[1]=0; dfs(1,1); cin>>Q; REP(i,Q){ int a,b; cin>>a>>b; cost[a]++; cost[b]++; if(lca(a,b)!=-1){ cost[lca(a,b)]--; if(parent[lca(a,b)]!=-1){ cost[parent[lca(a,b)]]--; } } } check2[1]=true; LL ans=imos(1); cout<