#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> edges;
vector<pair<long long, long long> > adj[300005];
bool vis[300005];
long long dis[300005], par[300005];
vector<long long> indices;
void dijkstra(long long cur, long long n) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      heap;
  heap.push(make_pair(0, cur));
  long long i;
  for (i = 0; i < 300005; i++) {
    dis[i] = LLONG_MAX;
    par[i] = -1;
  }
  dis[cur] = 0;
  while (!heap.empty()) {
    pair<long long, long long> p = heap.top();
    cur = p.second;
    heap.pop();
    if (vis[cur] == true) continue;
    if (par[cur] != -1)
      indices.push_back(
          edges[make_pair(min(par[cur], cur), max(cur, par[cur]))]);
    vis[cur] = true;
    for (i = 0; i < adj[cur].size(); i++) {
      long long child = adj[cur][i].first;
      if (!vis[child]) {
        if (dis[child] > dis[cur] + adj[cur][i].second) {
          dis[child] = dis[cur] + adj[cur][i].second;
          par[child] = cur;
          heap.push(make_pair(dis[child], child));
        }
      }
    }
  }
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  long long n, m, i, u, v, k, w;
  cin >> n >> m >> k;
  for (i = 0; i < m; i++) {
    cin >> u >> v >> w;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
    edges[make_pair(min(u, v), max(u, v))] = i + 1;
  }
  dijkstra(1, n);
  v = indices.size();
  cout << min(k, v) << endl;
  for (i = 0; i < min(k, v); i++) cout << indices[i] << " ";
  cout << endl;
  return 0;
}
