#include <bits/stdc++.h>
using namespace std;
struct rebr {
  int to, cost, index;
  bool in_ost = 0;
};
struct edge {
  int from, to, cost, index;
};
vector<vector<rebr> > g;
vector<edge> edges;
bool comp(edge e1, edge e2) {
  return (e1.cost == e2.cost ? e1.index < e2.index : e1.cost < e2.cost);
}
int get(int v) {
  edge now;
  int cost = 0;
  now.from = v;
  for (int i = 0; i < g[v].size(); i++) {
    if (!g[v][i].in_ost) continue;
    now.to = g[v][i].to;
    now.index = g[v][i].index;
    int delt = get(now.to);
    cost += delt;
    now.cost = delt;
    edges.push_back(now);
  }
  return cost + 1;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  g.resize(n);
  rebr x;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    x.to = v;
    x.cost = w;
    x.index = i;
    g[u].push_back(x);
    x.to = u;
    g[v].push_back(x);
  }
  vector<int> p(n, -1);
  set<pair<long long, int> > q;
  set<pair<int, int> > in_ost;
  vector<long long> d(n, 1e18);
  q.insert({0, 0});
  d[0] = 0;
  p[0] = 0;
  long long len;
  int to;
  int from;
  while (q.size()) {
    from = q.begin()->second;
    in_ost.insert({p[from], from});
    q.erase(q.begin());
    for (int i = 0; i < g[from].size(); i++) {
      len = g[from][i].cost;
      to = g[from][i].to;
      if (d[to] > d[from] + len) {
        q.erase({d[to], to});
        d[to] = d[from] + len;
        p[to] = from;
        q.insert({d[to], to});
      }
    }
  }
  for (int i = 0; i < g.size(); i++) {
    for (int j = 0; j < g[i].size(); j++) {
      if (in_ost.find(make_pair(i, g[i][j].to)) != in_ost.end()) {
        g[i][j].in_ost = 1;
      }
    }
  }
  get(0);
  sort(edges.rbegin(), edges.rend(), comp);
  cout << min(k, (int)edges.size()) << '\n';
  for (int i = 0; i < min(k, (int)edges.size()); i++) {
    cout << edges[i].index + 1 << ' ';
  }
}
