
# slower version:

s = input()
for i in range(len(s)):
  if i%2 == 0:
    print(s[i], end = '')


# optimized version of the same code:

s = input()
ans = ''
for i in range(len(s)):
  if i % 2 == 0:
    ans += s[i]
print(ans)



# slower version:

# bellman_ford : O(V E)

# dijkstra : O(E log V), 負辺は無理

# warshall_floyd : O(V**3)



import sys



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline





def solve():

    inf = 10 ** 14 + 10



    def dfs(v: 'vertex_index, 0-indexed') -> None:

        for c, t in e[v]:

            if d[t] != inf:

                continue

            d[t] = d[v] + c

            dfs(t)



    n = int(eval(input()))

    e = tuple(set() for _ in range(n))

    for _ in range(n - 1):

        a, b, c = list(map(int, input().split()))

        a -= 1

        b -= 1

        e[a].add((c, b))

        e[b].add((c, a))



    q, v = list(map(int, input().split()))

    v -= 1



    d = [inf] * n

    d[v] = 0



    dfs(v)



    for _ in range(q):

        x, y = list(map(int, input().split()))

        x -= 1

        y -= 1

        print((d[x] + d[y]))





if __name__ == '__main__':

    solve()


# optimized version of the same code:

# bellman_ford : O(V E)

# dijkstra : O(E log V), 負辺は無理

# warshall_floyd : O(V**3)

# deque



from collections import deque

import sys



input = sys.stdin.readline





def solve():

    inf = 10 ** 14 + 10



    n = int(eval(input()))

    e = tuple(set() for _ in range(n))

    for _ in range(n - 1):

        a, b, c = list(map(int, input().split()))

        a -= 1

        b -= 1

        e[a].add((c, b))

        e[b].add((c, a))



    q, v = list(map(int, input().split()))

    v -= 1



    d = [inf] * n

    d[v] = 0



    dq = deque()

    for cost, to in e[v]:

        dq.append((cost, to, v))

        # (cost, to, parent)



    while dq:

        c, v, p = dq.popleft()

        if d[v] != inf:

            continue

        d[v] = d[p] + c

        for cost, to in e[v]:

            if to == p:

                continue

            dq.append((cost, to, v))

            

    for _ in range(q):

        x, y = list(map(int, input().split()))

        x -= 1

        y -= 1

        print((d[x] + d[y]))





if __name__ == '__main__':

    solve()

# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)
import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline


def solve():
    inf = 10**14 + 10

    def dfs(v: "vertex_index, 0-indexed") -> None:
        for c, t in e[v]:
            if d[t] != inf:
                continue
            d[t] = d[v] + c
            dfs(t)

    n = int(eval(input()))
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        e[a].add((c, b))
        e[b].add((c, a))
    q, v = list(map(int, input().split()))
    v -= 1
    d = [inf] * n
    d[v] = 0
    dfs(v)
    for _ in range(q):
        x, y = list(map(int, input().split()))
        x -= 1
        y -= 1
        print((d[x] + d[y]))


if __name__ == "__main__":
    solve()

# bellman_ford : O(V E)
# dijkstra : O(E log V), 負辺は無理
# warshall_floyd : O(V**3)
# deque
from collections import deque
import sys

input = sys.stdin.readline


def solve():
    inf = 10**14 + 10
    n = int(eval(input()))
    e = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        e[a].add((c, b))
        e[b].add((c, a))
    q, v = list(map(int, input().split()))
    v -= 1
    d = [inf] * n
    d[v] = 0
    dq = deque()
    for cost, to in e[v]:
        dq.append((cost, to, v))
        # (cost, to, parent)
    while dq:
        c, v, p = dq.popleft()
        if d[v] != inf:
            continue
        d[v] = d[p] + c
        for cost, to in e[v]:
            if to == p:
                continue
            dq.append((cost, to, v))
    for _ in range(q):
        x, y = list(map(int, input().split()))
        x -= 1
        y -= 1
        print((d[x] + d[y]))


if __name__ == "__main__":
    solve()

+# deque +from collections import deque -sys.setrecursionlimit(10**7) - -    def dfs(v: "vertex_index, 0-indexed") -> None: -        for c, t in e[v]: -            if d[t] != inf: -                continue -            d[t] = d[v] + c -            dfs(t) - -    dfs(v) +    dq = deque() +    for cost, to in e[v]: +        dq.append((cost, to, v)) +        # (cost, to, parent) +    while dq: +        c, v, p = dq.popleft() +        if d[v] != inf: +            continue +        d[v] = d[p] + c +        for cost, to in e[v]: +            if to == p: +                continue +            dq.append((cost, to, v))