#include <bits/stdc++.h>
using namespace std;
clock_t __stt;
inline void TStart() { __stt = clock(); }
inline void TReport() {
  cerr << fixed << setprecision(3) << "\nCurrent Case Taken Time : "
       << (double)(clock() - __stt) / CLOCKS_PER_SEC << "sec\n";
}
template <typename T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T ABS(T a) {
  return a > 0 ? a : (-a);
}
template <typename T>
void UMIN(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void UMAX(T &a, T b) {
  if (b > a) a = b;
}
int n, s, m, x[55], dis[55][55], inrt[55], deg[55];
vector<pair<int, int> > adj[55];
void getdis(int s, int v, int f, int d) {
  int i;
  dis[s][v] = dis[v][s] = d;
  for (i = 0; i < (int)adj[v].size(); ++i) {
    int u = adj[v][i].first, w = adj[v][i].second;
    if (u != f) getdis(s, u, v, d + w);
  }
}
void dfs(int v, int f, int d, int s = -1) {
  inrt[v] = s;
  int i;
  for (i = 0; i < (int)adj[v].size(); ++i) {
    int u = adj[v][i].first, w = adj[v][i].second;
    if (u != f) {
      dfs(u, v, d + w, s == -1 ? u : s);
    }
  }
}
int dp[55][55];
int trans(vector<int> ds, vector<int> is, int pos, int cnm, int ocnm) {
  int i, j, k, cnt = (int)ds.size(), ret = 0;
  for (i = 0; i < cnt; ++i) {
    if (is[i] == pos) continue;
    int low = 1, high = cnm, mid;
    while (low < high) {
      mid = (low + high) / 2;
      int sum = mid, bnd = ds[i] + dp[is[i]][ocnm + cnm - mid];
      for (j = 0; j < cnt; ++j) {
        if (i == j) continue;
        int d = lower_bound(dp[is[j]], dp[is[j]] + ocnm + cnm, bnd - ds[j]) -
                dp[is[j]];
        sum += ocnm + cnm - d;
      }
      if (sum < cnm)
        low = mid + 1;
      else
        high = mid;
    }
    UMAX(ret, dp[is[i]][cnm + ocnm - low] + ds[i]);
  }
  return ret;
}
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n - 1; ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    --u;
    --v;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
    ++deg[u];
    ++deg[v];
  }
  scanf("%d%d", &s, &m);
  --s;
  for (i = 0; i < m; ++i) {
    scanf("%d", x + i);
    --x[i];
  }
  dfs(s, -1, 0);
  for (i = 0; i < n; ++i) getdis(i, i, -1, 0);
  for (j = 1; j <= m; ++j) {
    for (i = 0; i < n; ++i) {
      if (deg[i] != 1) continue;
      vector<int> ds, is;
      for (k = 0; k < n; ++k) {
        if (deg[k] == 1 && k != i) {
          ds.push_back(dis[i][k]);
          is.push_back(k);
        }
      }
      dp[i][j] = trans(ds, is, i, j, 0);
    }
  }
  int res = 2000000000;
  for (i = 0; i < (int)adj[s].size(); ++i) {
    int v = adj[s][i].first, w = adj[s][i].second, cnm = 0, gg = 0;
    for (j = 0; j < m; ++j) {
      cnm += (int)(inrt[x[j]] == v);
      if (x[j] == s) ++gg;
    }
    vector<int> ds, is;
    for (j = 0; j < n; ++j) {
      if (j != s && deg[j] == 1 && inrt[j] == v) {
        ds.push_back(dis[j][s]);
        is.push_back(j);
      }
    }
    if (cnm) UMIN(res, trans(ds, is, s, cnm, m - cnm - gg));
  }
  printf("%d\n", res);
  return 0;
}
