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 <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <bitset>
using namespace std;
const int N = 3e5 + 5;
const int LOG = 20;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;

long long ans;

int n, m;
vector<int> G[N];
int fa[N], dep[N], p[N][LOG];

void dfs(int u, int pre) {
    p[u][0] = fa[u] = pre;
    for (int i = 1; i < LOG; i++) {
        p[u][i] = p[p[u][i - 1]][i - 1];
    }
    for (int v : G[u]) {
        if (v == pre) continue;
        dep[v] = dep[u] + 1;
        dfs(v, u);
    }
}
int query_lca(int u, int v) {
    if (dep[u] < dep[v]) swap(u, v);
    for (int i = 0; i < LOG; i++) {
        if ((dep[u] - dep[v]) >> i & 1) u = p[u][i];
    }
    if (u == v) return u;
    for (int i = LOG - 1; ~i; i--) {
        if (p[u][i] != p[v][i]) {
            u = p[u][i];
            v = p[v][i];
        }
    }
    return p[u][0];
}

int find(int u, int anc) {
    int d = dep[u] - dep[anc] - 1;
    for (int i = 0; i < LOG; ++i) {
        if (d & (1 << i)) {
            u = p[u][i];
        }
    }
    return u;
}

struct Query {
    int u, v, x, y;
    Query(int _u, int _v, int _x, int _y) {
        u = _u; v = _v; x = _x; y = _y;
    }
};

vector<Query> Q[N];

map<pair<int, int>, int> Q1[N];
map<int, int> Q2[N];

int cnt1[N], cnt2[N];

void merge(map<int, int>& mp1, map<int, int>& mp2) {
    if (mp1.size() < mp2.size()) {
        mp1.swap(mp2);
    }
    for (auto it : mp2) {
        mp1[it.first] += it.second;
    }
}

void gao(int u, int pre) {
    for (int v : G[u]) {
        if (v == pre) continue;
        gao(v, u);
        cnt1[u] += cnt1[v];
        cnt2[u] += cnt2[v];
    }

    int all = cnt1[u];
    /*
    printf("node %d\nall = %d\n", u, all);

    for (auto it : cnt) {
        printf("cnt[%d] = %d\n", it.first, it.second);
    }*/

    long long tot = 0;

    for (auto &q : Q[u]) {
        if (q.x == -1 && q.y == -1) {
            ans += all;
            tot += Q[u].size() - 1;
        }
        else if (q.y == -1) {
            ans += all - cnt2[q.x];
            tot += Q[u].size() - Q2[u][q.x];
        }
        else {
            ans += all - cnt2[q.x] - cnt2[q.y];
            tot += Q[u].size() - Q2[u][q.x] - Q2[u][q.y] + Q1[u][{q.x, q.y}];
        }
    }
    ans += tot / 2;
}

namespace fastIO {
    #define BUF_SIZE 100000
    //fread -> read
    bool IOerror = 0;
    inline char nc() {
        static char buf[BUF_SIZE], *p1 = buf + BUF_SIZE, *pend = buf + BUF_SIZE;
        if(p1 == pend) {
            p1 = buf;
            pend = buf + fread(buf, 1, BUF_SIZE, stdin);
            if(pend == p1) {
                IOerror = 1;
                return -1;
            }
        }
        return *p1++;
    }
    inline bool blank(char ch) {
        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
    }
    inline void read(int &x) {
        char ch;
        while(blank(ch = nc()));
        if(IOerror) return;
        for(x = ch - '0'; (ch = nc()) >= '0' && ch <= '9'; x = x * 10 + ch - '0');
    }
    #undef BUF_SIZE
};
using namespace fastIO;

void add(int u, int x, int lca) {
    cnt1[u] += 1;
    cnt2[u] += 1;
    cnt1[lca] -= 1;
    cnt2[x] -= 1;
}

int main() {
    //scanf("%d", &n);
    read(n);
    for (int i = 1; i < n; ++i) {
        int u, v;
        //scanf("%d%d", &u, &v);
        read(u); read(v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0);
    //scanf("%d", &m);
    read(m);
    for (int i = 1; i <= m; ++i) {
        int u, v;
        //scanf("%d%d", &u, &v);
        read(u); read(v);
        int lca = query_lca(u, v);
        //printf("lca(%d, %d) = %d\n", u, v, lca);
        if (u == v) {
            Q[lca].push_back(Query(u, v, -1, -1));
        }
        else if (u == lca) {
            int y = find(v, lca);
            ++Q2[lca][y];
            add(v, y, lca);
            Q[lca].push_back(Query(v, u, y, -1));
        }
        else if (v == lca) {
            int x = find(u, lca);
            ++Q2[lca][x];
            add(u, x, lca);
            Q[lca].push_back(Query(u, v, x, -1));
        }
        else {
            int x = find(u, lca);
            int y = find(v, lca);
            if (x > y) {
                swap(x, y);
                swap(u, v);
            }
            ++Q1[lca][{x, y}];
            ++Q2[lca][x];
            ++Q2[lca][y];
            add(u, x, lca);
            add(v, y, lca);
            Q[lca].push_back(Query(u, v, x, y));
        }
    }
    gao(1, 0);
    printf("%lld\n", ans);
	return 0;
}

  	 		  	 	  	  			  	 		 	   	