#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> adj[(50 + 1)];
map<pair<int, int>, int> weight;
int dist[(50 + 1)][(50 + 1)];
int dp[(50 + 1)][(50 + 1)];
int pris[(50 + 1)];
vector<int> leaves[(50 + 1)];
int dfs(int curr, int par, int head) {
  int ans = 0;
  int child = 0;
  for (int nxt : adj[curr])
    if (nxt != par) ans += dfs(nxt, curr, head), child++;
  if (child == 0) leaves[head].push_back(curr);
  return pris[curr] + ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
    weight[{x, y}] = w;
    weight[{y, x}] = w;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (weight.count({i, j}) == 1) {
        dist[i][j] = weight[{i, j}];
        dist[j][i] = weight[{i, j}];
      } else {
        dist[i][j] = 1e9;
        dist[j][i] = 1e9;
      }
  for (int i = 0; i < n; i++) dist[i][i] = 0;
  int s;
  cin >> s;
  s--;
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    pris[x - 1]++;
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (dist[i][j] > (dist[i][k] + dist[k][j])) {
          dist[i][j] = dist[i][k] + dist[k][j];
          dist[j][i] = dist[i][k] + dist[k][j];
        }
      }
  for (int i = 0; i < n; i++) dfs(i, -1, i);
  for (int caught = 1; caught < m + 1; caught++) {
    for (int src = 0; src < n; src++) {
      int L = 0, R = 1e9;
      while (L <= R) {
        int c = caught;
        int COST = (L + R) >> 1;
        for (int nxt : leaves[src]) {
          int used = 0;
          while (used < c &&
                 COST <= (dp[nxt][caught - used - 1] + dist[src][nxt])) {
            used++;
          }
          c -= used;
        }
        if (c == 0) {
          dp[src][caught] = COST;
          L = COST + 1;
        } else
          R = COST - 1;
      }
    }
  }
  if (adj[s].size() == 1) {
    cout << dp[s][m];
    return 0;
  }
  int ans = numeric_limits<int>().max() / 2;
  for (int nxt : adj[s]) {
    int src = nxt;
    leaves[nxt] = vector<int>();
    int c = dfs(nxt, s, nxt);
    int cons = c;
    int L = 0, R = 1e9;
    while (L + 1 < R) {
      int c = cons;
      int COST = (L + R) >> 1;
      for (int nxt : leaves[src]) {
        if (nxt != s) {
          int used = 0;
          while (used < c && COST <= (dp[nxt][m - used - 1] + dist[s][nxt])) {
            used++;
          }
          c -= used;
        }
      }
      if (c == 0) {
        L = COST;
      } else
        R = COST;
    }
    ans = min(ans, L);
  }
  cout << ans;
  return 0;
}
