import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Edge = Tuple!(int, "to", int, "idx");

void main() {
    int N;
    scan(N);

    auto adj = new Edge[][](N, 0);

    foreach (i ; 0 .. N - 1) {
        int ai, bi;
        scan(ai, bi);
        ai--, bi--;
        adj[ai] ~= Edge(bi, i);
        adj[bi] ~= Edge(ai, i);
    }

    int M;
    scan(M);

    auto useEdge = new ulong[](M);

    ulong dfs(int u, int p, int v) {
        foreach (e ; adj[u]) if (e.to != p) {
            if (e.to == v) {
                return 1 << e.idx;
            }
            auto b = dfs(e.to, u, v);
            if (b != 0) {
                return b | (1 << e.idx);
            }
        }
        return 0;
    }

    foreach (i ; 0 .. M) {
        int ui, vi;
        scan(ui, vi);
        ui--, vi--;
        useEdge[i] = dfs(ui, -1, vi);
    }

    debug {
        writeln(useEdge);
    }

    long ans;

    foreach (s ; 0 .. (1 << M)) {
        ulong b;
        foreach (i ; 0 .. M) {
            if (s & (1 << i)) {
                b |= useEdge[i];
            }
        }
        auto p = s.popcnt % 2;
        auto t = (-1)^^p * 2^^(N - 1 - b._popcnt);
        ans += t;
    }

    writeln(ans);
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}
