#include <bits/stdc++.h>
using namespace std;
int n, m, k, a, b, c;
vector<pair<int, pair<int, int> > > v[300000 + 5];
priority_queue<pair<long long, pair<int, int> > > pq;
bool visited[300000 + 5];
vector<int> res;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    v[a].push_back(make_pair(b, make_pair(c, i + 1)));
    v[b].push_back(make_pair(a, make_pair(c, i + 1)));
  }
  if (k == 0) {
    printf("0\n");
    return 0;
  }
  pq.push(make_pair(0, make_pair(0, -1)));
  while (!pq.empty()) {
    pair<long long, pair<int, int> > top = pq.top();
    pq.pop();
    int nownode = top.second.first;
    int edge = top.second.second;
    long long nowcost = top.first;
    if (visited[nownode]) continue;
    visited[nownode] = true;
    if (edge > 0) {
      res.push_back(edge);
      if (res.size() == k) break;
    }
    for (int i = 0; i < v[nownode].size(); i++) {
      int targetnode = v[nownode][i].first;
      int targetcost = v[nownode][i].second.first;
      int idx = v[nownode][i].second.second;
      pq.push(make_pair(nowcost - targetcost, make_pair(targetnode, idx)));
    }
  }
  printf("%d\n", res.size());
  for (int i = 0; i < res.size(); i++) {
    printf("%d", res[i]);
    if (i == res.size() - 1)
      printf("\n");
    else
      printf(" ");
  }
}
