using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var graph = Enumerable.Repeat(0, (int)N).Select(_ => new List<(long to, long cost)>()).ToArray();
            for (var i = 0; i < N - 1; ++i)
            {
                var (a, b, c) = Slice3<long>();
                --a; --b;
                graph[a].Add((b, c));
                graph[b].Add((a, c));
            }
            var (Q, K) = Slice2<long>();
            var dsts = dijkstra(K - 1, graph);


            for (var i = 0; i < Q; ++i)
            {
                var (x, y) = Slice2<long>();
                WriteLine(dsts[x - 1] + dsts[y - 1]);
            }
        }
        class priority_queue<T>
        {
            Comparison<T> cmp;
            T[] A = new T[2000000];
            // var pq = new priority_queue<long>((l, r) => l.CompareTo(r));
            // とすれば値の大きいものから優先
            public priority_queue(Comparison<T> c)
            {
                cmp = c;
            }
            public int num { get; private set; } = 0;
            public void insert(T v)
            {
                A[num] = v;
                ++num;
                increaseKey(num);
            }
            void increaseKey(int i)
            {
                while (1 < i && 0 < cmp(A[i - 1], A[i / 2 - 1]))
                {
                    var t = A[i - 1];
                    A[i - 1] = A[i / 2 - 1];
                    A[i / 2 - 1] = t;
                    i = i / 2;
                }
            }
            public T extract()
            {
                if (num < 1) return default(T);
                var max = A[0];
                A[0] = A[num - 1];
                --num;
                maxHeapify(1);
                return max;
            }
            void maxHeapify(int i)
            {
                var H = num;
                var l = left(i);
                var r = right(i);
                var largest = 0;
                if (l <= H && 0 < cmp(A[l - 1], A[i - 1])) { largest = l; } else { largest = i; }
                if (r <= H && 0 < cmp(A[r - 1], A[largest - 1])) { largest = r; }
                if (largest != i)
                {
                    var t = A[i - 1];
                    A[i - 1] = A[largest - 1];
                    A[largest - 1] = t;
                    maxHeapify(largest);
                }
            }
            int left(int l) => l * 2;
            int right(int r) => r * 2 + 1;
        }

        static long[] dijkstra(long root, List<(long to, long cost)>[] M)
        {
            var n = M.Length;
            var q = new priority_queue<(long node, long dst)>((l, r) => r.dst.CompareTo(l.dst));
            var d = Enumerable.Repeat(long.MaxValue / 2, n).ToArray();
            var used = new bool[n];
            d[root] = 0;
            q.insert((root, 0));
            while (0 < q.num)
            {
                var v = q.extract();
                var u = v.node;
                used[u] = true;
                if (d[u] < v.dst) continue;
                foreach (var kv in M[u])
                {
                    var to = kv.to;
                    var cost = kv.cost;
                    if (used[to]) continue;
                    if (d[u] + cost < d[to])
                    {
                        d[to] = d[u] + cost;
                        q.insert((to, d[to]));
                    }
                }
            }
            return d;
        }
        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 64852