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.
//#pragma GCC optimize("O3")
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <stack>
#include <iomanip>
#include <bitset>
#include <map>
#include <cassert>
#include <array>
#include <queue>
#include <cstring>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define pqueue priority_queue
#define pb(x) push_back(x)
// #define endl '\n'
#define all(x) x.begin(), x.end()
 #define int long  long
      
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
      
const int inf = 1e9 + 228;
const ll infll = 1e18;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ld eps = 1e-14;
      
      
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    cout.tie(0);
   // freopen("a.in", "r", stdin);
//    freopen("outputik.txt", "w", stdout);
}

const int maxn = 3e5 + 228;

vi g[maxn];
int tin[maxn];
int tout[maxn];
int timer;
int up[maxn][20];
int add1[maxn];
int add2[maxn];
map<pair<int, int>, int> kek[maxn];


void dfs1(int v, int p = 0){
    up[v][0] = p;
    for(int i=1; i<20; i++)
        up[v][i] = up[up[v][i-1]][i-1];
    tin[v] = timer++;
    for(int i:g[v]){
        if(i == p)
            continue;
        dfs1(i, v);
    }
    tout[v] = timer++;
}

bool upper(int a, int b){
    return tin[a] <= tin[b] && tout[b] <= tout[a];
}

int lca(int a, int b){
    if(upper(a, b))
        return a;
    if(upper(b, a))
        return b;
    int cur = a;
    for(int i=19; i>=0; i--){
        if(!upper(up[cur][i], b))
            cur = up[cur][i];
    }
    return up[cur][0];
}

void dfs2(int v, int p = -1){
    for(int i:g[v]){
        if(i == p)
            continue;
        dfs2(i, v);
        add1[v] += add1[i];
        add2[v] += add2[i];
    }
}

void solve(){
    int n;
    cin >> n;
    for(int i=1; i<n; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    dfs1(0);
    int m;
    cin >> m;
    vpii lol(m);
    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        int kek = lca(a, b);
        add1[a]++;
        add1[b]++;
        add2[a]++;
        add2[b]++;
        add1[kek]--;
        add2[kek]-=2;
        if(kek)
            add1[up[kek][0]]--;
        if(upper(a, b) || upper(b, a)){
            if(!upper(a, b))
                swap(a, b);
            for(int i=19; i>=0; i--){
                if(upper(a, up[b][i]) && a != up[b][i])
                    b = up[b][i];
            }
            lol[i] = make_pair(a, b);
        } else{
            for(int i=19; i>=0; i--){
                if(upper(kek, up[a][i]) && up[a][i] != kek)
                    a = up[a][i];
            }   
            for(int i=19; i>=0; i--){
                if(upper(kek, up[b][i]) && up[b][i] != kek)
                    b = up[b][i];
            }
            ::kek[kek][make_pair(min(a, b), max(a, b))]++;
            lol[i] = make_pair(a, b);
        }
    }
    dfs2(0);
    int ans = 0;
    for(int i=0; i<m; i++){
        if(upper(lol[i].first, lol[i].second)){
            if(lol[i].first == lol[i].second){
                ans += add1[lol[i].first]-1;
                add1[lol[i].first]--;
            } else{
                int add = add1[lol[i].first]-1;
                add -= add2[lol[i].second]-1;
                ans += add;
                add1[lol[i].first]--;
                add2[lol[i].second]--;
            }
        } else{
            ans += add1[up[lol[i].first][0]] - 1;
            ans -= add2[lol[i].first]-1;
            ans -= add2[lol[i].second]-1;
            ans += ::kek[up[lol[i].first][0]][make_pair(min(lol[i].first, lol[i].second), max(lol[i].first, lol[i].second))]-1;
            add1[up[lol[i].first][0]]--;
            add2[lol[i].first]--;
            add2[lol[i].second]--;
            ::kek[up[lol[i].first][0]][make_pair(min(lol[i].first, lol[i].second), max(lol[i].first, lol[i].second))]--;
        }
    }
    cout << ans << endl;
}
  
signed main(){
    fast_io();
//    srand(time(NULL));
    cout << fixed << setprecision(10);
    int q = 1;
//    cin >> q;
    while(q--)
        solve();
}
