import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val ab = Array(n - 1) { sc.nextInt() - 1 to sc.nextInt() - 1 }
        val edges = Array(n) { arrayListOf<Pair<Int, Int>>() }
        for (i in 0 until n - 1) {
            val a = ab[i].first
            val b = ab[i].second
            edges[a].add(b to i)
            edges[b].add(a to i)
        }

        val m = sc.nextInt()
        val u = Array(m) { -1 }
        val v = Array(m) { -1 }

        for (i in 0 until m) {
            u[i] = sc.nextInt() - 1
            v[i] = sc.nextInt() - 1
        }

        val l = 1 shl m

        // 制約iに含まれる辺
        val b = Array(m) { 0L }

        fun search(i: Int, p: Int, q: Int, target: Int): Boolean {
            if (i == target) return true
            for (j in edges[i].indices) {
                if (edges[i][j].first == p) continue
                if (search(edges[i][j].first, i, q, target)) {
                    b[q] += (1L shl edges[i][j].second)
                    return true
                }
            }
            return false
        }

        for (i in 0 until m) {
            search(u[i], -1, i, v[i])
        }
        var ans = 0L
        for (i in 0 until (1 shl m)) {
            var flag = 0L
            var cnt = 0
            for (j in 0 until m) {
                if ((i and (1 shl j)) > 0) {
                    flag = flag or b[j]
                    cnt++
                }
            }

            var c = 1L
            for (j in 0 until n - 1) {
                if ((flag and (1L shl j)) == 0L) {
                    c *= 2
                }
            }

            if (cnt % 2 == 0) {
                ans += c
            } else {
                ans -= c
            }
        }

        println(ans)
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 48096