#include <bits/stdc++.h>
using namespace std;
const int maxN = 57;
const int INF = 1e9 + 7;
template <class T>
inline T rd() {
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  T x = 0;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f ? x : -x;
}
struct vec {
  static const int maxE = maxN;
  int g[maxN], te;
  struct edge {
    int y, d, nxt;
  } e[maxE << 1];
  vec() { te = 1; }
  inline void push(int x, int y, int d) {
    e[++te] = (edge){y, d, g[x]};
    g[x] = te;
  }
  inline void link(int x, int y, int d) { push(x, y, d), push(y, x, d); }
  inline int& operator()(int x) { return g[x]; }
  inline edge& operator[](int x) { return e[x]; }
} e;
int n, m, s;
int sz[maxN];
int f[maxN << 1][maxN];
int num[maxN], g[maxN], id, rt[maxN];
int deg[maxN];
int dis[maxN][maxN], bg;
void getsz(int x, int fa) {
  num[x] = id;
  for (int p = e(x), y = e[p].y; p; y = e[p = e[p].nxt].y)
    if (y != fa) {
      getsz(y, x);
      sz[x] += sz[y];
    }
}
void getdis(int x, int fa) {
  for (int p = e(x), y = e[p].y; p; y = e[p = e[p].nxt].y)
    if (y != fa) {
      dis[bg][y] = dis[bg][x] + e[p].d;
      getdis(y, x);
    }
}
int F(int x, int rest) {
  int& res = f[x][rest];
  if (~res) return res;
  if (rest == 0) return res = 0;
  int l = 0, r = INF, mid, sum;
  while (l != r) {
    mid = (l + r) / 2 + 1, sum = 0;
    for (int i = (1), _ = (n); i <= _; ++i)
      if (x != i && deg[i] == 1) {
        int j;
        for (j = 1; j <= rest; ++j)
          if (dis[x][i] + F(i, rest - j) < mid) break;
        sum += j - 1;
      }
    if (sum >= rest)
      l = mid;
    else
      r = mid - 1;
  }
  return res = l;
}
int main() {
  n = rd<int>();
  for (int i = (1), _ = (n); i < _; ++i) {
    int x = rd<int>(), y = rd<int>(), z = rd<int>();
    e.link(x, y, z);
    deg[x]++, deg[y]++;
  }
  for (int i = (1), _ = (n); i <= _; ++i) {
    dis[i][i] = 0;
    getdis(bg = i, 0);
  }
  s = rd<int>();
  m = rd<int>();
  for (int i = (1), _ = (m); i <= _; ++i) sz[rd<int>()]++;
  for (int p = e(s), y = e[p].y; p; y = e[p = e[p].nxt].y) {
    rt[++id] = y;
    getsz(y, s);
  }
  memset(f, -1, sizeof f);
  F(1, 2);
  int l = 0, r = INF, mid;
  while (l != r) {
    mid = (l + r) / 2 + 1;
    memset(g, 0, sizeof g);
    for (int i = (1), _ = (n); i <= _; ++i)
      if (i != s && deg[i] == 1) {
        int j;
        for (j = 1; j <= sz[rt[num[i]]]; ++j)
          if (dis[s][i] + F(i, m - j) < mid) break;
        g[num[i]] += j - 1;
      }
    bool ok = 1;
    for (int i = (1), _ = (id); i <= _; ++i)
      if (g[i] < sz[rt[i]]) ok = 0;
    if (ok)
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d\n", l);
  return 0;
}
