using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramD a = new ProgramD();
            a.main();//実行する

        }

    }

    class ProgramA
    {
        public void main()
        {

            string s = Console.ReadLine();

            if(s[0] == s[2])
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {

            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int d = int.Parse(s[3]);

            if (a > d || b < c)
                Console.WriteLine("0");
            else
                Console.WriteLine(Math.Abs(Math.Min(b, d) - Math.Max(a, c)));
            

        }
    }

    class ProgramC
    {
        public void main()
        {
            int n = int.Parse(Console.ReadLine());


            ulong ans = ulong.Parse(Console.ReadLine());

            for (int i = 1; i < n;i++)
            {
                ulong t = ulong.Parse(Console.ReadLine());
                ulong g = gcd(ans, t);
                ans = ans / g * t;

                
            }

            Console.WriteLine(ans);


        }

        /*最大公約数を求める関数*/
        static ulong gcd(ulong p, ulong q)
        {
            if (p < q)
            {
                ulong temp = p;
                p = q;
                q = temp;
            }

            ulong r = 1;

            while (r != 0)
            {
                r = p % q;
                p = q;
                q = r;
            }

            return p;
        }
    }

    class ProgramD
    {
        static int n;
        static List<Dis>[] tree;
        static long[] dis;
        static long[] tan;

        public void main()
        {
            n = int.Parse(Console.ReadLine());

            tree = new List<Dis>[n];
            dis = new long[n];
            tan = new long[n];


            for (int i = 0;i < n;i++)
                tree[i] = new List<Dis>();

            for (int i = 0; i < n - 1; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                int a = int.Parse(s[0]);
                int b = int.Parse(s[1]);
                long c = long.Parse(s[2]);
                tree[a - 1].Add(new Dis(b - 1, c));
                tree[b - 1].Add(new Dis(a - 1, c));
            }

            string[] t = Console.ReadLine().Split(' ');
            int q = int.Parse(t[0]);
            int m = int.Parse(t[1]);

            dis[m - 1] = 0;
            tan[m - 1] = -1;
            dfs(m - 1);

            for(int i = 0;i < q;i++)
            {
                string[] queri = Console.ReadLine().Split(' ');
                Console.WriteLine(dis[int.Parse(queri[0]) - 1] + dis[int.Parse(queri[1]) - 1]);
            }
           


        }

        public void dfs(int m)
        {
            for (int i = 0; i < tree[m].Count; i++)
            {
                if (tan[tree[m][i].a] != -1)
                {
                    tan[tree[m][i].a] = -1;
                    dis[tree[m][i].a] = dis[m] + tree[m][i].b;
                    dfs(tree[m][i].a);
                }
            }
            
        }
    }

    class Dis
    {
        public int a;
        public long b;
        public Dis(int a, long b)
        {
            this.a = a;
            this.b = b;
        }
    }
}






Measured memory_bytes: 47496