import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(N: Int, a: IntArray, b: IntArray, c: LongArray, Q: Int, K: Int, x: IntArray, y: IntArray){
    val tree = AdjacentListGraph<Int, Long>(Array(N){ Vertex<Int, Long>(it) }.toMutableList())
    for(i in 0 until N - 1){
        tree.addEdge(a[i] - 1, b[i] - 1, c[i])
        tree.addEdge(b[i] - 1, a[i] - 1, c[i])
    }
    val distances = distancesFrom(tree, K - 1, 0L){ a, b -> a + b }
    // println(distances.toList())
    repeat(Q){
        val ans = distances[x[it] - 1]!! + distances[y[it] - 1]!!
        pw.println(ans)
    }
    pw.flush()
    return
}

interface Graph<T : Comparable<T>, E : Comparable<E>> {
    val size: Int
    fun getWeight(from: Int, to: Int): E?
    fun edgesFrom(from: Int): List<Edge<E>>
    fun addEdge(from: Int, to: Int, weight: E): Boolean
    fun removeEdge(from: Int, to: Int): Boolean
    fun isAdjacent(from: Int, to: Int): Boolean
}


inline fun <reified T : Comparable<T>, reified E : Comparable<E>> distancesFrom(
    graph: Graph<T, E>,
    from: Int,
    empty: E,
    combine: (E, E) -> E
): Array<E?> {
    val distances = Array<E?>(graph.size) { null }
    val queue = ArrayDeque<Int>()
    distances[from] = empty
    queue.add(from)
    while (queue.size > 0) {
        val node = queue.removeFirst()
        val currentDist = distances[node]!!
        graph.edgesFrom(node).filter { distances[it.to] == null }.forEach {
            distances[it.to] = combine(currentDist, it.weight)
            queue.add(it.to)
        }
    }
    return distances
}

data class Edge<T : Comparable<T>>(val to: Int, val weight: T)

data class Vertex<T : Comparable<T>, E : Comparable<E>>(val data: T) {
    val edges = mutableListOf<Edge<E>>()

    fun addEdge(to: Int, weight: E): Boolean{
        edges.add(Edge(to, weight))
        return true
    }

    fun removeEdge(to: Int): Boolean {
        for ((i, edge) in edges.withIndex()) {
            if (edge.to == to) {
                edges.removeAt(i)
                return true
            }
        }
        return false
    }
}

class AdjacentListGraph<T : Comparable<T>, E : Comparable<E>>(
    val vertices: MutableList<Vertex<T, E>>
) : Graph<T, E> {
    override val size = vertices.size
    override fun getWeight(from: Int, to: Int): E? =
        vertices[from].edges.find { it.to == to }?.weight
    override fun edgesFrom(from: Int): List<Edge<E>> = vertices[from].edges
    override fun addEdge(from: Int, to: Int, weight: E) = vertices[from].addEdge(to, weight)
    override fun removeEdge(from: Int, to: Int) = vertices[from].removeEdge(to)
    override fun isAdjacent(from: Int, to: Int) =
        vertices[from].edges.find { it.to == to } != null
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = IntArray(N-1)
    val b = IntArray(N-1)
    val c = LongArray(N-1)
    for (i in 0 until N-1) {
        a[i] = sc.next().toInt()
        b[i] = sc.next().toInt()
        c[i] = sc.next().toLong()
    }
    val Q = sc.next().toInt()
    val K = sc.next().toInt()
    val x = IntArray(Q.toInt())
    val y = IntArray(Q.toInt())
    for (i in 0 until Q.toInt()) {
        x[i] = sc.next().toInt()
        y[i] = sc.next().toInt()
    }
    solve(N, a, b, c, Q, K, x, y)
}



Measured memory_bytes: 105292