from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions,pprint

sys.setrecursionlimit(10**8)

mod = 10**9+7

mod2 = 998244353

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))



n = inp()

g = [[] for i in range(n)]

cc = dict()

for i in range(n-1):

    a,b,c = inpl()

    a -= 1

    b -= 1

    g[a].append(b)

    g[b].append(a)

    cc[(a,b)] = c

    cc[(b,a)] = c

q,k = inpl()

k -= 1

cost = [INF] * n

cost[k] = 0

def dfs(node,c):

    for next in g[node]:

        if cost[next] == INF:

            cost[next] = c + cc[(node,next)]

            dfs(next,cost[next])



dfs(k,0)

res = [0] * q

for i in range(q):

    x,y = inpl()

    x -= 1

    y -= 1

    res[i] = cost[x] + cost[y]

for z in res:

    print(z)

from collections import Counter,defaultdict,deque

from heapq import heappop,heappush,heapify

import sys,bisect,math,itertools,fractions

from decimal import Decimal

sys.setrecursionlimit(10**8)

mod = 10**9+7

INF = float('inf')

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))



n = inp()

co = dict()

g = [[] for _ in range(n)]

cost = [-1] * n

for i in range(n-1):

    a,b,c = inpl()

    a -= 1; b -= 1

    g[a] += [b]; g[b] += [a]

    co[(a,b)] = c; co[(b,a)] = c

Q,k = inpl()

k -= 1; cost[k] = 0

q = deque()

q.append(k)

while q:

    nv = q.popleft()

    for v in g[nv]:

        if cost[v] > 0:

            continue

        cost[v] = cost[nv] + co[(v,nv)]

        q.append(v)

for _ in range(Q):

    a,b = inpl()

    a -= 1; b -= 1

    print((cost[a] + cost[b]))
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions, pprint

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
mod2 = 998244353
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


def inpln(n):
    return list(int(sys.stdin.readline()) for i in range(n))


n = inp()
g = [[] for i in range(n)]
cc = dict()
for i in range(n - 1):
    a, b, c = inpl()
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
    cc[(a, b)] = c
    cc[(b, a)] = c
q, k = inpl()
k -= 1
cost = [INF] * n
cost[k] = 0


def dfs(node, c):
    for next in g[node]:
        if cost[next] == INF:
            cost[next] = c + cc[(node, next)]
            dfs(next, cost[next])


dfs(k, 0)
res = [0] * q
for i in range(q):
    x, y = inpl()
    x -= 1
    y -= 1
    res[i] = cost[x] + cost[y]
for z in res:
    print(z)

from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heapify
import sys, bisect, math, itertools, fractions
from decimal import Decimal

sys.setrecursionlimit(10**8)
mod = 10**9 + 7
INF = float("inf")


def inp():
    return int(sys.stdin.readline())


def inpl():
    return list(map(int, sys.stdin.readline().split()))


n = inp()
co = dict()
g = [[] for _ in range(n)]
cost = [-1] * n
for i in range(n - 1):
    a, b, c = inpl()
    a -= 1
    b -= 1
    g[a] += [b]
    g[b] += [a]
    co[(a, b)] = c
    co[(b, a)] = c
Q, k = inpl()
k -= 1
cost[k] = 0
q = deque()
q.append(k)
while q:
    nv = q.popleft()
    for v in g[nv]:
        if cost[v] > 0:
            continue
        cost[v] = cost[nv] + co[(v, nv)]
        q.append(v)
for _ in range(Q):
    a, b = inpl()
    a -= 1
    b -= 1
    print((cost[a] + cost[b]))

-import sys, bisect, math, itertools, fractions, pprint +import sys, bisect, math, itertools, fractions +from decimal import Decimal -mod2 = 998244353 -def inpln(n): -    return list(int(sys.stdin.readline()) for i in range(n)) - - -g = [[] for i in range(n)] -cc = dict() +co = dict() +g = [[] for _ in range(n)] +cost = [-1] * n -    g[a].append(b) -    g[b].append(a) -    cc[(a, b)] = c -    cc[(b, a)] = c -q, k = inpl() +    g[a] += [b] +    g[b] += [a] +    co[(a, b)] = c +    co[(b, a)] = c +Q, k = inpl() -cost = [INF] * n - - -def dfs(node, c): -    for next in g[node]: -        if cost[next] == INF: -            cost[next] = c + cc[(node, next)] -            dfs(next, cost[next]) - - -dfs(k, 0) -res = [0] * q -for i in range(q): -    x, y = inpl() -    x -= 1 -    y -= 1 -    res[i] = cost[x] + cost[y] -for z in res: -    print(z) +q = deque() +q.append(k) +while q: +    nv = q.popleft() +    for v in g[nv]: +        if cost[v] > 0: +            continue +        cost[v] = cost[nv] + co[(v, nv)] +        q.append(v) +for _ in range(Q): +    a, b = inpl() +    a -= 1 +    b -= 1 +    print((cost[a] + cost[b]))