#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
template <typename T>
bool is_prime_sqrt(T n) {
  if (n == 1) return false;
  T k = trunc(sqrt(n));
  for (T i = 2; i <= k; i++)
    if (n % i == 0) return false;
  return true;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const int two = 2;
const long long sr = 31;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 601;
const int MAX_T = (1 << 20);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 21;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int vr, e, n, k, dist[MAX_N][MAX_N], pos[MAX_N];
int pa[MAX_N], pb[MAX_N];
vector<vector<int> > v(MAX_N);
bool used[MAX_N];
bool dfs(int p) {
  used[p] = true;
  for (int i : v[p]) {
    if (pb[i] == -1 || (!used[pb[i]] && dfs(pb[i]))) {
      pa[p] = i;
      pb[i] = p;
      return true;
    }
  }
  return false;
}
void kuhn() {
  memset(pa, -1, sizeof(pa));
  memset(pb, -1, sizeof(pb));
  for (int i = 0; i < n; i++) {
    memset(used, 0, sizeof(used));
    if (dfs(i)) continue;
  }
}
bool check(int h) {
  v.clear();
  v.resize(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < vr; j++)
      if (dist[pos[i]][j] <= h) v[i].push_back(j);
  kuhn();
  int kol = 0;
  for (int i = 0; i < n; i++) kol += (pa[i] != -1);
  return (kol >= k);
}
int main() {
  cin.sync_with_stdio(0);
  cin >> vr >> e >> n >> k;
  for (int i = 0; i < vr; i++)
    for (int j = 0; j < vr; j++) dist[i][j] = BIG;
  for (int i = 0; i < vr; i++) dist[i][i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> pos[i];
    pos[i]--;
  }
  for (int i = 0; i < e; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--, b--;
    dist[a][b] = min(dist[a][b], t);
    dist[b][a] = min(dist[b][a], t);
  }
  for (int h = 0; h < vr; h++)
    for (int i = 0; i < vr; i++)
      for (int j = 0; j < vr; j++)
        dist[i][j] = min(dist[i][h] + dist[h][j], dist[i][j]);
  if (check(0)) {
    cout << 0;
    return 0;
  }
  int l = 0;
  int r = 1731315;
  if (!check(r)) {
    cout << -1;
    return 0;
  }
  while (r - l > 1) {
    int h = (l + r) / 2;
    if (check(h))
      r = h;
    else
      l = h;
  }
  cout << r;
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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;
template <typename T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
template <typename T>
bool is_prime_sqrt(T n) {
  if (n == 1) return false;
  T k = trunc(sqrt(n));
  for (T i = 2; i <= k; i++)
    if (n % i == 0) return false;
  return true;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const int two = 2;
const long long sr = 31;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 601;
const int MAX_T = (1 << 20);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 21;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int vr, e, n, k, dist[MAX_N][MAX_N], pos[MAX_N];
int pa[MAX_N], pb[MAX_N];
vector<vector<int> > v(MAX_N);
bool used[MAX_N];
bool dfs(int p) {
  used[p] = true;
  for (int i : v[p]) {
    if (pb[i] == -1 || (!used[pb[i]] && dfs(pb[i]))) {
      pa[p] = i;
      pb[i] = p;
      return true;
    }
  }
  return false;
}
void kuhn() {
  memset(pa, -1, sizeof(pa));
  memset(pb, -1, sizeof(pb));
  for (int i = 0; i < n; i++) {
    memset(used, 0, sizeof(used));
    if (dfs(i)) continue;
  }
}
bool check(int h) {
  v.clear();
  v.resize(n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < vr; j++)
      if (dist[pos[i]][j] <= h) v[i].push_back(j);
  kuhn();
  int kol = 0;
  for (int i = 0; i < n; i++) kol += (pa[i] != -1);
  return (kol >= k);
}
int main() {
  cin.sync_with_stdio(0);
  cin >> vr >> e >> n >> k;
  for (int i = 0; i < vr; i++)
    for (int j = 0; j < vr; j++) dist[i][j] = BIG;
  for (int i = 0; i < vr; i++) dist[i][i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> pos[i];
    pos[i]--;
  }
  for (int i = 0; i < e; i++) {
    int a, b, t;
    cin >> a >> b >> t;
    a--, b--;
    dist[a][b] = min(dist[a][b], t);
    dist[b][a] = min(dist[b][a], t);
  }
  for (int h = 0; h < vr; h++)
    for (int i = 0; i < vr; i++)
      for (int j = 0; j < vr; j++)
        dist[i][j] = min(dist[i][h] + dist[h][j], dist[i][j]);
  if (check(0)) {
    cout << 0;
    return 0;
  }
  int l = 0;
  int r = 1731315;
  if (!check(r)) {
    cout << -1;
    return 0;
  }
  while (r - l > 1) {
    int h = (l + r) / 2;
    if (check(h))
      r = h;
    else
      l = h;
  }
  cout << r;
  return 0;
}

```