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.
/**
 ____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 300002;
const int M_MAX = 300002;

const int BITS = 22;

int n;

vector <int> edges[N_MAX];

struct Path
{
    int u, v;
};

int m;

Path p[M_MAX];

int parent[N_MAX];
int depth[N_MAX];

void dfs (int u)
{
    for(int v : edges[u])
        if(v != parent[u])
        {
            parent[v] = u;
            depth[v] = depth[u] + 1;
            dfs(v);
        }
}

int anc[N_MAX][BITS];

int ancestor (int u, int k)
{
    int bit = 0;
    while(k > 0)
    {
        if(k & 1)
            u = anc[u][bit];
        bit++;
        k >>= 1;
    }
    return u;
}

int getLCA (int u, int v)
{
    if(depth[u] > depth[v])
        u = ancestor(u, depth[u] - depth[v]);
    else
        v = ancestor(v, depth[v] - depth[u]);
    if(u == v)
        return u;
    for(int bit = BITS - 1; bit >= 0; bit--)
        if(anc[u][bit] != anc[v][bit])
        {
            u = anc[u][bit];
            v = anc[v][bit];
        }
    return parent[u];
}

int LCA[M_MAX];

int son1[M_MAX], son2[M_MAX];

int mars[N_MAX];

ll sumSons[N_MAX];

void doMars (int u)
{
    for(int v : edges[u])
        if(v != parent[u])
        {
            doMars(v);
            mars[u] += mars[v];
        }
}

vector <int> LCAv[N_MAX];

map <int, int> onemp;
map <pair <int, int>, int> bothmp;

ll cntDisjoint (vector <pair <int, int>> &v)
{
    onemp.clear();
    bothmp.clear();
    ll ans = 0;
    int aux = 0;
    for(pair <int, int> &x : v)
    {
        ans += aux - onemp[x.first] - onemp[x.second] + bothmp[x];
        aux++;
        if(x.first != 0)
            onemp[x.first]++;
        if(x.second != 0)
            onemp[x.second]++;
        if(x.first != 0 && x.second != 0)
            bothmp[x]++;
    }
    return ans;
}

int down (int u, int v)
{
    return ancestor(v, depth[v] - depth[u] - 1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    cin >> m;
    for(int i = 1; i <= m; i++)
        cin >> p[i].u >> p[i].v;
    dfs(1);
    for(int i = 1; i <= n; i++)
        anc[i][0] = parent[i];
    for(int bit = 1; bit < BITS; bit++)
        for(int i = 1; i <= n; i++)
            anc[i][bit] = anc[anc[i][bit - 1]][bit - 1];
    for(int i = 1; i <= m; i++)
        LCA[i] = getLCA(p[i].u, p[i].v);
    for(int i = 1; i <= m; i++)
    {
        if(p[i].u != LCA[i])
        {
            mars[p[i].u]++;
            mars[down(LCA[i], p[i].u)]--;
        }
        if(p[i].v != LCA[i])
        {
            mars[p[i].v]++;
            mars[down(LCA[i], p[i].v)]--;
        }
        LCAv[LCA[i]].push_back(i);
        if(p[i].u != LCA[i])
            son1[i] = down(LCA[i], p[i].u);
        if(p[i].v != LCA[i])
            son2[i] = down(LCA[i], p[i].v);
        if(son1[i] > son2[i])
            swap(son1[i], son2[i]);
    }
    doMars(1);
    ll ans = 0;
    /// LCA IN CHAIN
    for(int i = 1; i <= n; i++)
    {
        for(int j : edges[i])
            if(j != parent[i])
                sumSons[i] += mars[j];
    }
    for(int i = 1; i <= m; i++)
        ans += sumSons[LCA[i]] - mars[son1[i]] - mars[son2[i]];
    /// LCA COMMON
    for(int i = 1; i <= n; i++)
    {
        vector <pair <int, int>> v;
        for(int j : LCAv[i])
            v.push_back(make_pair(son1[j], son2[j]));
        ans += cntDisjoint(v);
    }
    /// LCA END OF CHAIN
    for(int i = 1; i <= m; i++)
    {
        if(p[i].u != LCA[i])
            ans += LCAv[p[i].u].size();
        if(p[i].v != LCA[i])
            ans += LCAv[p[i].v].size();
    }
    cout << ans << "\n";
    return 0;
}
