#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

//typedef long long ll;
typedef int ll;

ll const INF = 1<<29;

struct EDGE {
  ll u, v, c;
  EDGE(ll u=0, ll v=0, ll c=INF) : u(u), v(v), c(c)
  {}
  bool operator < (EDGE const& e) const {
    return c < e.c;
  }
};

struct Edge {
  ll to, cost;
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

Graph g;
vector<ll> d;
vector<set<ll> > vlist;
ll N, M, K;
vector<vector<EDGE> > v;

set<ll> ans;
bool memo[110][1100];  //[idx][depth]
vector<EDGE> es;

void dfs(int idx, ll depth) {
  if(memo[idx][depth]) return;
  if(depth == K) {
    ans.insert(idx);
  }
  memo[idx][depth] = 1;
  rep(i, g[idx].size()) {
    Edge& e = g[idx][i];
    if(!vlist[depth].count(e.to)) continue;
    if(d[depth] != e.cost) continue;
    dfs(e.to, depth+1);
  }
}

int main() {
  
  cin >> N >> M >> K;
  es.resize(M);
  g.resize(N+1);
  rep(i, M) {
    ll a, b, c; cin >> a >> b >> c; a--, b--;
    es[i].u = a, es[i].v = b, es[i].c = c;
  }
  
  d.resize(K);
  rep(i, K) cin >> d[i];
  
  sort(es.begin(), es.end());
  es.push_back(EDGE(0,0,INF));
  v.resize(K);
  rep(i, K) {
    auto uiter = upper_bound(es.begin(), es.end(), EDGE(0,0,d[i]));
    auto liter = lower_bound(es.begin(), es.end(), EDGE(0,0,d[i]));
    
    for(auto iter=liter; iter!=uiter; iter++) {
      v[i].push_back(*iter);
    }
  }
  
  vlist.resize(K);
  rep(i, K) {
    rep(j, v[i].size()) {
      vlist[i].insert(v[i][j].u);
      vlist[i].insert(v[i][j].v);
      g[v[i][j].u].push_back((Edge){v[i][j].v, v[i][j].c});
      g[v[i][j].v].push_back((Edge){v[i][j].u, v[i][j].c});
    }
  }
  
  for(auto e: vlist[0]) {
    dfs(e, 0);
  }
  
  cout << ans.size() << endl;
  bool f = 0;
  for(auto e: ans) {
    if(f) cout << " ";
    f = 1;
    cout << e+1;
  }
  cout << endl;
  
  return 0;
}