import java.util.*

val limit = 100010


class Connection(connect: Int, distance: Long) {
    val connect = connect
    val distance = distance
}

//val connect = Array<MutableList<Int>>(limit, { mutableListOf() })
//val distance = Array<MutableList<Long>>(limit, { mutableListOf() })

val connections = Array<MutableList<Connection>>(limit, { mutableListOf() })

val distanceFromRoot = Array<Long>(limit, { 0 })

fun getDistanceFromRoot(now: Int, parent: Int, nowDistance: Long) {
    distanceFromRoot[now] = nowDistance
    for (i in 0..connections[now].size - 1) {
        if (connections[now][i].connect == parent) {
            continue
        }
        getDistanceFromRoot(connections[now][i].connect, now, nowDistance + connections[now][i].distance)
    }
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    
    for (i in 1..n-1) {
        val a = cin.nextInt() - 1
        val b = cin.nextInt() - 1
        val c = cin.nextLong()

        //connect[a].add(b)
        //connect[b].add(a)
        //distance[a].add(c)
        //distance[b].add(c)
        connections[a].add(Connection(b, c))
        connections[b].add(Connection(a, c))
    }

    val q = cin.nextInt()
    val k = cin.nextInt() - 1

    getDistanceFromRoot(k, -1, 0)

    /* 幅優先の木の構築
    val parent = Array<Int>(n, { -1 })
    val queue: MutableList<Int> = mutableListOf(k)

    while (queue.size != 0) {
        val now = queue.removeAt(0)
        for (i in 0..connect[now].size - 1) {
            val children = connect[now]
            if (children[i] != parent[now]) {
                distanceFromRoot[children[i]] = distanceFromRoot[now] + distance[now][i]
                queue.add(children[i])
                parent[children[i]] = now
            }
        }
    }
    */

    for (i in 0..q-1) {
        val x = cin.nextInt() - 1
        val y = cin.nextInt() - 1
        println(distanceFromRoot[x]+distanceFromRoot[y])
    }
}