import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.{Comparator, StringTokenizer}

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    type Edge = ((Int, Int), Int)
    val E = Array.fill[ListBuffer[(Int, Int)]](N)(ListBuffer.empty)
    (0 until N - 1) foreach { _ =>
      val a, b = sc.nextInt() - 1
      val c = sc.nextInt()
      E(a) += ((b, c))
      E(b) += ((a, c))
    }

    val Q, K = sc.nextInt()
    val INF = 1000000000 * N
    val d = Array.fill[Long](N)(INF)
    d(K - 1) = 0

    def toEdges(v: Int): Seq[Edge] =
      E(v) collect { case (u, c) if d(u) == INF => ((v, u), c)}

    var q = E(K -1) map { case (b, c) => ((K - 1, b), c)}
    while(q.nonEmpty) {
      q = q flatMap { case ((a, b), c) =>
        d(b) = d(a) + c
        toEdges(b)
      }
    }

    (0 until Q) foreach { _ =>
      val x, y = sc.nextInt() - 1
      println(d(x) + d(y))
    }
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}
