#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 100005;
typedef long long LL;
int pre[N], nxt[N * 2], w[N * 2], to[N * 2], cnt = 0;
void addEdge(int x, int y, int v) {
  w[cnt] = v;
  nxt[cnt] = pre[x];
  to[pre[x] = cnt++] = y;
}
LL dep[N];
void dfs(int x, int f) {
  for (int i = pre[x]; ~i; i = nxt[i])
    if (to[i] != f) {
      dep[to[i]] = dep[x] + w[i];
      dfs(to[i], x);
    }
}
int main() {
  memset(pre, -1, sizeof pre);
  int n, x, y, v;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d%d", &x, &y, &v);
    addEdge(x, y, v);
    addEdge(y, x, v);
  }
  int q, k;
  scanf("%d%d", &q, &k);
  dep[k] = 0;
  dfs(k, -1);
  while (q--) {
    scanf("%d%d", &x, &y);
    printf("%lld\n", dep[x] + dep[y]);
  }
  return 0;
}
