#include <bits/stdc++.h>
using namespace std;
int S, T;
int num_edges = 0;
int start[(610 * 2)];
int to[((610 + 610 * 610 + 610) * 2)], cap[((610 + 610 * 610 + 610) * 2)],
    succ[((610 + 610 * 610 + 610) * 2)];
void _add_edge(int a, int b, int c) {
  to[num_edges] = b;
  cap[num_edges] = c;
  succ[num_edges] = start[a];
  start[a] = num_edges;
  num_edges++;
}
void add_edge(int a, int b, int c) {
  _add_edge(a, b, c);
  _add_edge(b, a, 0);
}
void clear_edges() {
  num_edges = 0;
  fill(start, start + (610 * 2), -1);
}
bool seen[(610 * 2)];
int from[(610 * 2)];
void bfs() {
  fill(seen, seen + (610 * 2), false);
  fill(from, from + (610 * 2), -1);
  queue<int> q;
  q.push(S);
  seen[S] = true;
  while (!q.empty()) {
    int at = q.front();
    q.pop();
    for (int i = start[at]; i != -1; i = succ[i]) {
      if (cap[i] <= 0) continue;
      if (seen[to[i]]) continue;
      from[to[i]] = i;
      seen[to[i]] = true;
      q.push(to[i]);
    }
  }
}
int augment() {
  bfs();
  if (!seen[T]) return 0;
  int path_flow = INT_MAX;
  for (int at = T; at != S; at = to[from[at] ^ 1]) {
    path_flow = min(path_flow, cap[from[at]]);
  }
  for (int at = T; at != S; at = to[from[at] ^ 1]) {
    cap[from[at]] -= path_flow;
    cap[from[at] ^ 1] += path_flow;
  }
  return path_flow;
}
int max_flow() {
  int mf = 0;
  int path_flow;
  while ((path_flow = augment())) mf += path_flow;
  return mf;
}
int V, E, N, K;
int teams[(610 * 2)];
int G[(610 * 2)][(610 * 2)];
bool can(int max_time) {
  clear_edges();
  for (int i = 0; i < V; i++) {
    if (teams[i] == 0) continue;
    add_edge(S, i, teams[i]);
    for (int j = 0; j < V; j++) {
      if (G[i][j] <= max_time) add_edge(i, j + V, 205);
    }
  }
  for (int i = 0; i < V; i++) {
    add_edge(i + V, T, 1);
  }
  int mf = max_flow();
  return mf >= K;
}
int main() {
  cin >> V >> E >> N >> K;
  S = 2 * V;
  T = 2 * V + 1;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    teams[p - 1]++;
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) G[i][j] = INT_MAX / 2 - 5;
    G[i][i] = 0;
  }
  for (int i = 0; i < E; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--;
    b--;
    G[a][b] = G[b][a] = min(G[a][b], t);
  }
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int l = -1;
  int r = 1731311 + 1;
  while (l < r - 1) {
    int m = (l + r) / 2;
    if (can(m))
      r = m;
    else
      l = m;
  }
  if (r == 1731311 + 1)
    printf("-1\n");
  else
    printf("%d\n", r);
}

### Prompt

Please formulate a CPP solution to the following problem:

The competitors of Bubble Cup X gathered after the competition and discussed what is the best way to get to know the host country and its cities.

After exploring the map of Serbia for a while, the competitors came up with the following facts: the country has V cities which are indexed with numbers from 1 to V, and there are E bi-directional roads that connect the cites. Each road has a weight (the time needed to cross that road). There are N teams at the Bubble Cup and the competitors came up with the following plan: each of the N teams will start their journey in one of the V cities, and some of the teams share the starting position.

They want to find the shortest time T, such that every team can move in these T minutes, and the number of different cities they end up in is at least K (because they will only get to know the cities they end up in). A team doesn't have to be on the move all the time, if they like it in a particular city, they can stay there and wait for the time to pass.

Please help the competitors to determine the shortest time T so it's possible for them to end up in at least K different cities or print -1 if that is impossible no matter how they move.

Note that there can exist multiple roads between some cities.

Input

The first line contains four integers: V, E, N and K (1 ≤ V ≤ 600, 1 ≤ E ≤ 20000, 1 ≤ N ≤ min(V, 200), 1 ≤ K ≤ N), number of cities, number of roads, number of teams and the smallest number of different cities they need to end up in, respectively.

The second line contains N integers, the cities where the teams start their journey.

Next E lines contain information about the roads in following format: Ai Bi Ti (1 ≤ Ai, Bi ≤ V, 1 ≤ Ti ≤ 10000), which means that there is a road connecting cities Ai and Bi, and you need Ti minutes to cross that road.

Output

Output a single integer that represents the minimal time the teams can move for, such that they end up in at least K different cities or output -1 if there is no solution.

If the solution exists, result will be no greater than 1731311.

Example

Input

6 7 5 4
5 5 2 2 5
1 3 3
1 5 2
1 6 5
2 5 4
2 6 7
3 4 11
3 5 3


Output

3

Note

Three teams start from city 5, and two teams start from city 2. If they agree to move for 3 minutes, one possible situation would be the following: Two teams in city 2, one team in city 5, one team in city 3 , and one team in city 1. And we see that there are four different cities the teams end their journey at.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int S, T;
int num_edges = 0;
int start[(610 * 2)];
int to[((610 + 610 * 610 + 610) * 2)], cap[((610 + 610 * 610 + 610) * 2)],
    succ[((610 + 610 * 610 + 610) * 2)];
void _add_edge(int a, int b, int c) {
  to[num_edges] = b;
  cap[num_edges] = c;
  succ[num_edges] = start[a];
  start[a] = num_edges;
  num_edges++;
}
void add_edge(int a, int b, int c) {
  _add_edge(a, b, c);
  _add_edge(b, a, 0);
}
void clear_edges() {
  num_edges = 0;
  fill(start, start + (610 * 2), -1);
}
bool seen[(610 * 2)];
int from[(610 * 2)];
void bfs() {
  fill(seen, seen + (610 * 2), false);
  fill(from, from + (610 * 2), -1);
  queue<int> q;
  q.push(S);
  seen[S] = true;
  while (!q.empty()) {
    int at = q.front();
    q.pop();
    for (int i = start[at]; i != -1; i = succ[i]) {
      if (cap[i] <= 0) continue;
      if (seen[to[i]]) continue;
      from[to[i]] = i;
      seen[to[i]] = true;
      q.push(to[i]);
    }
  }
}
int augment() {
  bfs();
  if (!seen[T]) return 0;
  int path_flow = INT_MAX;
  for (int at = T; at != S; at = to[from[at] ^ 1]) {
    path_flow = min(path_flow, cap[from[at]]);
  }
  for (int at = T; at != S; at = to[from[at] ^ 1]) {
    cap[from[at]] -= path_flow;
    cap[from[at] ^ 1] += path_flow;
  }
  return path_flow;
}
int max_flow() {
  int mf = 0;
  int path_flow;
  while ((path_flow = augment())) mf += path_flow;
  return mf;
}
int V, E, N, K;
int teams[(610 * 2)];
int G[(610 * 2)][(610 * 2)];
bool can(int max_time) {
  clear_edges();
  for (int i = 0; i < V; i++) {
    if (teams[i] == 0) continue;
    add_edge(S, i, teams[i]);
    for (int j = 0; j < V; j++) {
      if (G[i][j] <= max_time) add_edge(i, j + V, 205);
    }
  }
  for (int i = 0; i < V; i++) {
    add_edge(i + V, T, 1);
  }
  int mf = max_flow();
  return mf >= K;
}
int main() {
  cin >> V >> E >> N >> K;
  S = 2 * V;
  T = 2 * V + 1;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    teams[p - 1]++;
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) G[i][j] = INT_MAX / 2 - 5;
    G[i][i] = 0;
  }
  for (int i = 0; i < E; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--;
    b--;
    G[a][b] = G[b][a] = min(G[a][b], t);
  }
  for (int k = 0; k < V; k++) {
    for (int i = 0; i < V; i++) {
      for (int j = 0; j < V; j++) {
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }
  int l = -1;
  int r = 1731311 + 1;
  while (l < r - 1) {
    int m = (l + r) / 2;
    if (can(m))
      r = m;
    else
      l = m;
  }
  if (r == 1731311 + 1)
    printf("-1\n");
  else
    printf("%d\n", r);
}

```