#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int VM = 2520;
const int EM = 400010;
const int INF = 0x3f3f3f3f;
struct Edge {
  int u, v, nxt;
  int flow;
} edge[EM << 1];
int n, m, cnt, head[VM];
int src, des, dep[VM];
void addedge(int cu, int cv, int cf) {
  edge[cnt].u = cu;
  edge[cnt].v = cv;
  edge[cnt].flow = cf;
  edge[cnt].nxt = head[cu];
  head[cu] = cnt++;
  edge[cnt].u = cv;
  edge[cnt].v = cu;
  edge[cnt].flow = 0;
  edge[cnt].nxt = head[cv];
  head[cv] = cnt++;
}
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int legal(int i, int j, int k) {
  int x = i + dir[k][0];
  int y = j + dir[k][1];
  return x >= 1 && x <= n && y >= 1 && y <= m;
}
int BFS() {
  queue<int> q;
  while (!q.empty()) q.pop();
  memset(dep, -1, sizeof(dep));
  dep[src] = 0;
  q.push(src);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i != -1; i = edge[i].nxt) {
      int v = edge[i].v;
      if (edge[i].flow > 0 && dep[v] == -1) {
        dep[v] = dep[u] + 1;
        q.push(v);
      }
    }
  }
  return dep[des] != -1;
}
int DFS(int u, int minx) {
  int ans = 0;
  if (u == des) return minx;
  for (int i = head[u]; i != -1 && ans < minx; i = edge[i].nxt) {
    int v = edge[i].v;
    if (edge[i].flow > 0 && dep[v] == dep[u] + 1) {
      int tmp = min(edge[i].flow, minx - ans);
      tmp = DFS(v, tmp);
      ans += tmp;
      edge[i].flow -= tmp;
      edge[i ^ 1].flow += tmp;
    }
  }
  if (!ans) dep[u] = -2;
  return ans;
}
int Dinic() {
  int ans = 0, tmp;
  while (BFS()) {
    while (1) {
      tmp = DFS(src, INF);
      if (tmp == 0) break;
      ans += tmp;
    }
  }
  return ans;
}
int start[205], mp0[605][605];
int main() {
  int V, E, N, K;
  scanf("%d %d %d %d", &V, &E, &N, &K);
  for (int i = 1; i <= N; i++) scanf("%d", &start[i]);
  for (int i = 1; i <= V; i++)
    for (int i0 = 1; i0 <= V; i0++)
      if (i != i0) mp0[i][i0] = INT_MAX / 2;
  while (E--) {
    int A, B, T;
    scanf("%d %d %d", &A, &B, &T);
    mp0[B][A] = mp0[A][B] = min(mp0[A][B], T);
  }
  for (int k = 1; k <= V; k++)
    for (int x = 1; x <= V; x++)
      for (int y = 1; y <= V; y++)
        mp0[x][y] = min(mp0[x][y], mp0[x][k] + mp0[k][y]);
  int l = 0, r = 1731312;
  while (l < r) {
    int mid = (l + r) / 2;
    cnt = 0;
    memset(head, -1, sizeof(head));
    int x, y, z, s = N + V + 1, t = s + 1;
    for (int i = 1; i <= N; i++) {
      x = s, y = i, z = 1;
      addedge(x, y, z);
      for (int i0 = 1; i0 <= V; i0++) {
        x = i, y = i0 + N, z = 1;
        if (mp0[start[i]][i0] <= mid) addedge(x, y, z);
      }
    }
    for (int i = 1; i <= V; i++) {
      x = N + i, y = t, z = 1;
      addedge(x, y, z);
    }
    src = s, des = t;
    if (Dinic() >= K)
      r = mid;
    else
      l = mid + 1;
  }
  if (l < 1731312)
    printf("%d\n", l);
  else
    printf("-1\n");
  return 0;
}

### Prompt

In cpp, your task is to solve 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;
using namespace std;
const int VM = 2520;
const int EM = 400010;
const int INF = 0x3f3f3f3f;
struct Edge {
  int u, v, nxt;
  int flow;
} edge[EM << 1];
int n, m, cnt, head[VM];
int src, des, dep[VM];
void addedge(int cu, int cv, int cf) {
  edge[cnt].u = cu;
  edge[cnt].v = cv;
  edge[cnt].flow = cf;
  edge[cnt].nxt = head[cu];
  head[cu] = cnt++;
  edge[cnt].u = cv;
  edge[cnt].v = cu;
  edge[cnt].flow = 0;
  edge[cnt].nxt = head[cv];
  head[cv] = cnt++;
}
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int legal(int i, int j, int k) {
  int x = i + dir[k][0];
  int y = j + dir[k][1];
  return x >= 1 && x <= n && y >= 1 && y <= m;
}
int BFS() {
  queue<int> q;
  while (!q.empty()) q.pop();
  memset(dep, -1, sizeof(dep));
  dep[src] = 0;
  q.push(src);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i != -1; i = edge[i].nxt) {
      int v = edge[i].v;
      if (edge[i].flow > 0 && dep[v] == -1) {
        dep[v] = dep[u] + 1;
        q.push(v);
      }
    }
  }
  return dep[des] != -1;
}
int DFS(int u, int minx) {
  int ans = 0;
  if (u == des) return minx;
  for (int i = head[u]; i != -1 && ans < minx; i = edge[i].nxt) {
    int v = edge[i].v;
    if (edge[i].flow > 0 && dep[v] == dep[u] + 1) {
      int tmp = min(edge[i].flow, minx - ans);
      tmp = DFS(v, tmp);
      ans += tmp;
      edge[i].flow -= tmp;
      edge[i ^ 1].flow += tmp;
    }
  }
  if (!ans) dep[u] = -2;
  return ans;
}
int Dinic() {
  int ans = 0, tmp;
  while (BFS()) {
    while (1) {
      tmp = DFS(src, INF);
      if (tmp == 0) break;
      ans += tmp;
    }
  }
  return ans;
}
int start[205], mp0[605][605];
int main() {
  int V, E, N, K;
  scanf("%d %d %d %d", &V, &E, &N, &K);
  for (int i = 1; i <= N; i++) scanf("%d", &start[i]);
  for (int i = 1; i <= V; i++)
    for (int i0 = 1; i0 <= V; i0++)
      if (i != i0) mp0[i][i0] = INT_MAX / 2;
  while (E--) {
    int A, B, T;
    scanf("%d %d %d", &A, &B, &T);
    mp0[B][A] = mp0[A][B] = min(mp0[A][B], T);
  }
  for (int k = 1; k <= V; k++)
    for (int x = 1; x <= V; x++)
      for (int y = 1; y <= V; y++)
        mp0[x][y] = min(mp0[x][y], mp0[x][k] + mp0[k][y]);
  int l = 0, r = 1731312;
  while (l < r) {
    int mid = (l + r) / 2;
    cnt = 0;
    memset(head, -1, sizeof(head));
    int x, y, z, s = N + V + 1, t = s + 1;
    for (int i = 1; i <= N; i++) {
      x = s, y = i, z = 1;
      addedge(x, y, z);
      for (int i0 = 1; i0 <= V; i0++) {
        x = i, y = i0 + N, z = 1;
        if (mp0[start[i]][i0] <= mid) addedge(x, y, z);
      }
    }
    for (int i = 1; i <= V; i++) {
      x = N + i, y = t, z = 1;
      addedge(x, y, z);
    }
    src = s, des = t;
    if (Dinic() >= K)
      r = mid;
    else
      l = mid + 1;
  }
  if (l < 1731312)
    printf("%d\n", l);
  else
    printf("-1\n");
  return 0;
}

```