#include <bits/stdc++.h>
using namespace std;
typedef const char* cstr;
const int oo = (~0u) >> 1;
const long long int ooll = (~0ull) >> 1;
const double inf = 1e+20;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MOD = 1000000007;
template <typename type>
inline bool cmax(type& a, const type& b) {
  return a < b ? a = b, true : false;
}
template <typename type>
inline bool cmin(type& a, const type& b) {
  return b < a ? a = b, true : false;
}
template <typename type>
inline type sqr(const type& first) {
  return first * first;
}
inline int dbcmp(const double& a, const double& b) {
  return (a > b + eps) - (a < b - eps);
}
inline int sgn(const double& first) { return dbcmp(first, 0); }
template <typename type>
inline type cross(const pair<type, type>& a, const pair<type, type>& b,
                  const pair<type, type>& c) {
  return (b.first - a.first) * (c.second - a.second) -
         (b.second - a.second) * (c.first - a.first);
}
template <typename type>
inline type dot(const pair<type, type>& a, const pair<type, type>& b,
                const pair<type, type>& c) {
  return (b.first - a.first) * (c.first - a.first) +
         (b.second - a.second) * (c.second - a.second);
}
template <typename type>
inline type gcd(type a, type b) {
  if (b)
    while ((a %= b) && (b %= a))
      ;
  return a + b;
}
template <typename type>
inline type lcm(type a, type b) {
  return a * b / gcd(a, b);
}
template <typename type>
inline void bit_inc(vector<type>& st, int first, type inc) {
  while (first < ((int)(st).size())) st[first] += inc, first |= first + 1;
}
template <typename type>
inline type bit_sum(const vector<type>& st, int first) {
  type s = 0;
  while (first >= 0) s += st[first], first = (first & (first + 1)) - 1;
  return s;
}
template <typename type>
inline type bit_kth(const vector<type>& st, int k) {
  int first = 0, second = 0, z = 0;
  while ((1 << (++second)) < ((int)(st).size()))
    ;
  for (int i = (second - 1); i >= 0; --i) {
    if ((first += 1 << i) > ((int)(st).size()) || z + st[first - 1] > k)
      first -= 1 << i;
    else
      z += st[first - 1];
  }
  return first;
}
inline void make_set(vector<int>& set) {
  for (int i = (0); i < (((int)(set).size())); ++i) set[i] = i;
}
inline int find_set(vector<int>& set, int first) {
  int second = first, z;
  while (second != set[second]) second = set[second];
  while (first != set[first]) z = set[first], set[first] = second, first = z;
  return second;
}
inline bool union_set(vector<int>& set, int a, int b) {
  a = find_set(set, a), b = find_set(set, b);
  return a != b ? set[a] = b, true : false;
}
template <typename type>
inline void merge(type& a, type& b) {
  if (((int)(a).size()) < ((int)(b).size())) swap(a, b);
  for (typename type::iterator it = b.begin(); it != b.end(); b.erase(it++))
    a.insert(*it);
}
template <typename type>
inline void merge(priority_queue<type>& a, priority_queue<type>& b) {
  if (((int)(a).size()) < ((int)(b).size())) swap(a, b);
  while (((int)(b).size())) a.push(b.top()), b.pop();
}
struct Initializer {
  Initializer() { ios::sync_with_stdio(false); }
  ~Initializer() { cerr; }
} initializer;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > adj(n);
  vector<vector<int> > len(n);
  for (int i = (0); i < (m); ++i) {
    int u, v, w;
    cin >> u >> v >> w, --u, --v;
    adj[u].push_back(v);
    len[u].push_back(w);
    adj[v].push_back(u);
    len[v].push_back(w);
  }
  int k;
  cin >> k;
  vector<bool> isp(n);
  for (int i = (0); i < (k); ++i) {
    int p;
    cin >> p, --p;
    isp[p] = true;
  }
  long long int ans;
  {
    priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,
                   greater<pair<long long int, int> > >
        q;
    vector<long long int> d(n, ooll);
    vector<int> rt(n);
    for (int i = (0); i < (n); ++i)
      if (isp[i])
        if (cmin(d[i], 0ll)) q.push(make_pair(d[i], i)), rt[i] = i;
    while (((int)(q).size())) {
      if (d[q.top().second] == q.top().first) {
        int u = q.top().second;
        for (int i = (0); i < (((int)(adj[u]).size())); ++i) {
          int v = adj[u][i], l = len[u][i];
          if (cmin(d[v], d[u] + l)) q.push(make_pair(d[v], v)), rt[v] = rt[u];
        }
      }
      q.pop();
    }
    ans = d[0];
    vector<pair<long long int, pair<int, int> > > edges;
    for (int u = (0); u < (n); ++u)
      for (int i = (0); i < (((int)(adj[u]).size())); ++i) {
        int v = adj[u][i], l = len[u][i];
        edges.push_back(make_pair(d[u] + d[v] + l, make_pair(rt[u], rt[v])));
      }
    sort((edges).begin(), (edges).end());
    vector<int> st(n);
    make_set(st);
    for (int i = (0); i < (((int)(edges).size())); ++i) {
      int u = edges[i].second.first, v = edges[i].second.second;
      if (union_set(st, u, v)) ans += edges[i].first;
    }
  }
  cout << ans << '\n';
}

### Prompt

In cpp, your task is to solve the following problem:

Pavel plays a famous computer game. A player is responsible for a whole country and he can travel there freely, complete quests and earn experience.

This country has n cities connected by m bidirectional roads of different lengths so that it is possible to get from any city to any other one. There are portals in k of these cities. At the beginning of the game all portals are closed. When a player visits a portal city, the portal opens. Strange as it is, one can teleport from an open portal to an open one. The teleportation takes no time and that enables the player to travel quickly between rather remote regions of the country.

At the beginning of the game Pavel is in city number 1. He wants to open all portals as quickly as possible. How much time will he need for that?

Input

The first line contains two space-separated integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 105) that show how many cities and roads are in the game.

Each of the next m lines contains the description of a road as three space-separated integers xi, yi, wi (1 ≤ xi, yi ≤ n, xi ≠ yi, 1 ≤ wi ≤ 109) — the numbers of the cities connected by the i-th road and the time needed to go from one city to the other one by this road. Any two cities are connected by no more than one road. It is guaranteed that we can get from any city to any other one, moving along the roads of the country.

The next line contains integer k (1 ≤ k ≤ n) — the number of portals.

The next line contains k space-separated integers p1, p2, ..., pk — numbers of the cities with installed portals. Each city has no more than one portal.

Output

Print a single number — the minimum time a player needs to open all portals.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

3 3
1 2 1
1 3 1
2 3 1
3
1 2 3


Output

2


Input

4 3
1 2 1
2 3 5
2 4 10
3
2 3 4


Output

16


Input

4 3
1 2 1000000000
2 3 1000000000
3 4 1000000000
4
1 2 3 4


Output

3000000000

Note

In the second sample the player has to come to city 2, open a portal there, then go to city 3, open a portal there, teleport back to city 2 and finally finish the journey in city 4.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
typedef const char* cstr;
const int oo = (~0u) >> 1;
const long long int ooll = (~0ull) >> 1;
const double inf = 1e+20;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int MOD = 1000000007;
template <typename type>
inline bool cmax(type& a, const type& b) {
  return a < b ? a = b, true : false;
}
template <typename type>
inline bool cmin(type& a, const type& b) {
  return b < a ? a = b, true : false;
}
template <typename type>
inline type sqr(const type& first) {
  return first * first;
}
inline int dbcmp(const double& a, const double& b) {
  return (a > b + eps) - (a < b - eps);
}
inline int sgn(const double& first) { return dbcmp(first, 0); }
template <typename type>
inline type cross(const pair<type, type>& a, const pair<type, type>& b,
                  const pair<type, type>& c) {
  return (b.first - a.first) * (c.second - a.second) -
         (b.second - a.second) * (c.first - a.first);
}
template <typename type>
inline type dot(const pair<type, type>& a, const pair<type, type>& b,
                const pair<type, type>& c) {
  return (b.first - a.first) * (c.first - a.first) +
         (b.second - a.second) * (c.second - a.second);
}
template <typename type>
inline type gcd(type a, type b) {
  if (b)
    while ((a %= b) && (b %= a))
      ;
  return a + b;
}
template <typename type>
inline type lcm(type a, type b) {
  return a * b / gcd(a, b);
}
template <typename type>
inline void bit_inc(vector<type>& st, int first, type inc) {
  while (first < ((int)(st).size())) st[first] += inc, first |= first + 1;
}
template <typename type>
inline type bit_sum(const vector<type>& st, int first) {
  type s = 0;
  while (first >= 0) s += st[first], first = (first & (first + 1)) - 1;
  return s;
}
template <typename type>
inline type bit_kth(const vector<type>& st, int k) {
  int first = 0, second = 0, z = 0;
  while ((1 << (++second)) < ((int)(st).size()))
    ;
  for (int i = (second - 1); i >= 0; --i) {
    if ((first += 1 << i) > ((int)(st).size()) || z + st[first - 1] > k)
      first -= 1 << i;
    else
      z += st[first - 1];
  }
  return first;
}
inline void make_set(vector<int>& set) {
  for (int i = (0); i < (((int)(set).size())); ++i) set[i] = i;
}
inline int find_set(vector<int>& set, int first) {
  int second = first, z;
  while (second != set[second]) second = set[second];
  while (first != set[first]) z = set[first], set[first] = second, first = z;
  return second;
}
inline bool union_set(vector<int>& set, int a, int b) {
  a = find_set(set, a), b = find_set(set, b);
  return a != b ? set[a] = b, true : false;
}
template <typename type>
inline void merge(type& a, type& b) {
  if (((int)(a).size()) < ((int)(b).size())) swap(a, b);
  for (typename type::iterator it = b.begin(); it != b.end(); b.erase(it++))
    a.insert(*it);
}
template <typename type>
inline void merge(priority_queue<type>& a, priority_queue<type>& b) {
  if (((int)(a).size()) < ((int)(b).size())) swap(a, b);
  while (((int)(b).size())) a.push(b.top()), b.pop();
}
struct Initializer {
  Initializer() { ios::sync_with_stdio(false); }
  ~Initializer() { cerr; }
} initializer;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > adj(n);
  vector<vector<int> > len(n);
  for (int i = (0); i < (m); ++i) {
    int u, v, w;
    cin >> u >> v >> w, --u, --v;
    adj[u].push_back(v);
    len[u].push_back(w);
    adj[v].push_back(u);
    len[v].push_back(w);
  }
  int k;
  cin >> k;
  vector<bool> isp(n);
  for (int i = (0); i < (k); ++i) {
    int p;
    cin >> p, --p;
    isp[p] = true;
  }
  long long int ans;
  {
    priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,
                   greater<pair<long long int, int> > >
        q;
    vector<long long int> d(n, ooll);
    vector<int> rt(n);
    for (int i = (0); i < (n); ++i)
      if (isp[i])
        if (cmin(d[i], 0ll)) q.push(make_pair(d[i], i)), rt[i] = i;
    while (((int)(q).size())) {
      if (d[q.top().second] == q.top().first) {
        int u = q.top().second;
        for (int i = (0); i < (((int)(adj[u]).size())); ++i) {
          int v = adj[u][i], l = len[u][i];
          if (cmin(d[v], d[u] + l)) q.push(make_pair(d[v], v)), rt[v] = rt[u];
        }
      }
      q.pop();
    }
    ans = d[0];
    vector<pair<long long int, pair<int, int> > > edges;
    for (int u = (0); u < (n); ++u)
      for (int i = (0); i < (((int)(adj[u]).size())); ++i) {
        int v = adj[u][i], l = len[u][i];
        edges.push_back(make_pair(d[u] + d[v] + l, make_pair(rt[u], rt[v])));
      }
    sort((edges).begin(), (edges).end());
    vector<int> st(n);
    make_set(st);
    for (int i = (0); i < (((int)(edges).size())); ++i) {
      int u = edges[i].second.first, v = edges[i].second.second;
      if (union_set(st, u, v)) ans += edges[i].first;
    }
  }
  cout << ans << '\n';
}

```