#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2> p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
auto printVector = []<typename T>(ostream& out, vector<T> v) {
  copy(v.begin(), v.end(), ostream_iterator<T>(out, " "));
};
const int MAXN = 1500, MAXM = 400010, DIRECTED = 0, UNDIRECTED = 1;
const int INFTY = 0x3fffffff;
int N, S, T, now;
struct edge {
  int remain;
  int endVertexId, nextEdgeId;
} e[MAXM << 1];
struct vertex {
  int firstEdgeId, level, firstUnsaturEdgeId;
} v[MAXN];
void _addEdge(int begin, int end, int c) {
  e[now].remain = c;
  e[now].endVertexId = end;
  e[now].nextEdgeId = v[begin].firstEdgeId;
  v[begin].firstEdgeId = now++;
}
void addEdge(int begin, int end, int c, int edgeType) {
  _addEdge(begin, end, c);
  _addEdge(end, begin, edgeType * c);
}
void init() {
  now = 0;
  for (int i = 0; i < N; ++i) v[i].firstEdgeId = -1;
}
bool markLevel() {
  for (int i = 0; i < N; ++i)
    v[i].level = -1, v[i].firstUnsaturEdgeId = v[i].firstEdgeId;
  v[S].level = 0;
  queue<int> Q;
  Q.push(S);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = v[x].firstEdgeId; i >= 0; i = e[i].nextEdgeId)
      if (e[i].remain && v[e[i].endVertexId].level < 0)
        v[e[i].endVertexId].level = v[x].level + 1, Q.push(e[i].endVertexId);
  }
  return v[T].level > 0;
}
int extendFlow(int x, int flow) {
  if (x == T) return flow;
  int t, total = 0;
  for (int& i = v[x].firstUnsaturEdgeId; i >= 0; i = e[i].nextEdgeId) {
    if (v[e[i].endVertexId].level == v[x].level + 1 && e[i].remain) {
      if (t = extendFlow(e[i].endVertexId, min(flow, e[i].remain)))
        e[i].remain -= t, e[i ^ 1].remain += t, flow -= t, total += t;
      if (0 == flow) break;
    }
  }
  return total;
}
int Dinic() {
  int flow, total = 0;
  while (markLevel())
    while (flow = extendFlow(S, INFTY)) total += flow;
  return total;
}
int V, E, n, k, dist[610][610], st[610];
bool buildGraph(int mid) {
  N = 2 * V + 2;
  S = 0;
  T = N - 1;
  init();
  for (int i = 1; i <= V; i++)
    for (int j = 1; j <= V; j++)
      if (dist[i][j] <= mid) addEdge(i, j + V, 1, DIRECTED);
  for (int i = 1; i <= V; i++) {
    addEdge(S, i, st[i], DIRECTED);
    addEdge(i + V, T, 1, DIRECTED);
  }
  return Dinic() >= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> V >> E >> n >> k;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    st[x]++;
  }
  for (int i = 1; i <= V; i++)
    for (int j = i + 1; j <= V; j++) dist[i][j] = dist[j][i] = MOD;
  for (int i = 1, x, y, t; i <= E; i++) {
    cin >> x >> y >> t;
    dist[x][y] = min(dist[x][y], t);
    dist[y][x] = dist[x][y];
  }
  for (int k = 1; k <= V; k++)
    for (int i = 1; i <= V; i++)
      for (int j = 1; j <= V; j++)
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
  int l = -1, r = 1731312;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (buildGraph(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == 1731312)
    cout << -1 << endl;
  else
    cout << r << endl;
  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 ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;
template <typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2> p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
auto printVector = []<typename T>(ostream& out, vector<T> v) {
  copy(v.begin(), v.end(), ostream_iterator<T>(out, " "));
};
const int MAXN = 1500, MAXM = 400010, DIRECTED = 0, UNDIRECTED = 1;
const int INFTY = 0x3fffffff;
int N, S, T, now;
struct edge {
  int remain;
  int endVertexId, nextEdgeId;
} e[MAXM << 1];
struct vertex {
  int firstEdgeId, level, firstUnsaturEdgeId;
} v[MAXN];
void _addEdge(int begin, int end, int c) {
  e[now].remain = c;
  e[now].endVertexId = end;
  e[now].nextEdgeId = v[begin].firstEdgeId;
  v[begin].firstEdgeId = now++;
}
void addEdge(int begin, int end, int c, int edgeType) {
  _addEdge(begin, end, c);
  _addEdge(end, begin, edgeType * c);
}
void init() {
  now = 0;
  for (int i = 0; i < N; ++i) v[i].firstEdgeId = -1;
}
bool markLevel() {
  for (int i = 0; i < N; ++i)
    v[i].level = -1, v[i].firstUnsaturEdgeId = v[i].firstEdgeId;
  v[S].level = 0;
  queue<int> Q;
  Q.push(S);
  while (!Q.empty()) {
    int x = Q.front();
    Q.pop();
    for (int i = v[x].firstEdgeId; i >= 0; i = e[i].nextEdgeId)
      if (e[i].remain && v[e[i].endVertexId].level < 0)
        v[e[i].endVertexId].level = v[x].level + 1, Q.push(e[i].endVertexId);
  }
  return v[T].level > 0;
}
int extendFlow(int x, int flow) {
  if (x == T) return flow;
  int t, total = 0;
  for (int& i = v[x].firstUnsaturEdgeId; i >= 0; i = e[i].nextEdgeId) {
    if (v[e[i].endVertexId].level == v[x].level + 1 && e[i].remain) {
      if (t = extendFlow(e[i].endVertexId, min(flow, e[i].remain)))
        e[i].remain -= t, e[i ^ 1].remain += t, flow -= t, total += t;
      if (0 == flow) break;
    }
  }
  return total;
}
int Dinic() {
  int flow, total = 0;
  while (markLevel())
    while (flow = extendFlow(S, INFTY)) total += flow;
  return total;
}
int V, E, n, k, dist[610][610], st[610];
bool buildGraph(int mid) {
  N = 2 * V + 2;
  S = 0;
  T = N - 1;
  init();
  for (int i = 1; i <= V; i++)
    for (int j = 1; j <= V; j++)
      if (dist[i][j] <= mid) addEdge(i, j + V, 1, DIRECTED);
  for (int i = 1; i <= V; i++) {
    addEdge(S, i, st[i], DIRECTED);
    addEdge(i + V, T, 1, DIRECTED);
  }
  return Dinic() >= k;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> V >> E >> n >> k;
  for (int i = 0, x; i < n; i++) {
    cin >> x;
    st[x]++;
  }
  for (int i = 1; i <= V; i++)
    for (int j = i + 1; j <= V; j++) dist[i][j] = dist[j][i] = MOD;
  for (int i = 1, x, y, t; i <= E; i++) {
    cin >> x >> y >> t;
    dist[x][y] = min(dist[x][y], t);
    dist[y][x] = dist[x][y];
  }
  for (int k = 1; k <= V; k++)
    for (int i = 1; i <= V; i++)
      for (int j = 1; j <= V; j++)
        if (dist[i][j] > dist[i][k] + dist[k][j])
          dist[i][j] = dist[i][k] + dist[k][j];
  int l = -1, r = 1731312;
  while (l + 1 < r) {
    int mid = (l + r) >> 1;
    if (buildGraph(mid))
      r = mid;
    else
      l = mid;
  }
  if (r == 1731312)
    cout << -1 << endl;
  else
    cout << r << endl;
  return 0;
}

```