#include <bits/stdc++.h>
using namespace std;
struct EdgeData {
 public:
  int vertex;
  unsigned long long int weight;
  int num;
};
class Graph {
 public:
  int n;
  vector<vector<EdgeData>> edges;
  EdgeData onedata;
  Graph(int n) {
    this->n = n;
    vector<EdgeData> v;
    for (int i = 0; i <= n; ++i) {
      edges.push_back(v);
    }
  }
  void add_edge(int x, int y, unsigned long long int w, int cnt) {
    onedata.vertex = y;
    onedata.weight = w;
    onedata.num = cnt;
    edges[x].push_back(onedata);
    onedata.vertex = x;
    edges[y].push_back(onedata);
  }
};
class VertexData {
 public:
  bool processed;
  int edge_number;
  unsigned long long int weight;
};
void Dijkstra(int v, Graph* g, int k, vector<int>* edges) {
  VertexData onedata;
  onedata.weight = 18446744073709551615;
  onedata.processed = false;
  vector<VertexData> data;
  for (int i = 0; i <= g->n; ++i) {
    data.push_back(onedata);
  }
  data[v].edge_number = 0;
  data[v].weight = 0;
  priority_queue<pair<unsigned long long int, int>,
                 vector<pair<unsigned long long int, int>>,
                 greater<pair<unsigned long long int, int>>>
      q;
  q.push(make_pair(0, 1));
  while (q.size() > 0) {
    if (edges->size() == k) {
      return;
    }
    pair<unsigned long long int, int> curr = q.top();
    q.pop();
    if (data[curr.second].processed) {
      continue;
    }
    for (int i = 0; i < g->edges[curr.second].size(); ++i) {
      int vertex = g->edges[curr.second][i].vertex;
      unsigned long long int w = g->edges[curr.second][i].weight;
      if (!data[vertex].processed) {
        if (data[vertex].weight >= w + data[curr.second].weight) {
          data[vertex].weight = w + data[curr.second].weight;
          data[vertex].processed = false;
          data[vertex].edge_number = g->edges[curr.second][i].num;
          q.push(make_pair(data[vertex].weight, vertex));
        }
      }
    }
    if (curr.second != 1) {
      edges->push_back(data[curr.second].edge_number);
    }
    data[curr.second].processed = true;
  }
  return;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  Graph g(n);
  int x, y;
  unsigned long long int w;
  for (int i = 1; i <= m; ++i) {
    cin >> x >> y >> w;
    g.add_edge(x, y, w, i);
  }
  vector<int> edges;
  Dijkstra(1, &g, k, &edges);
  cout << edges.size() << endl;
  for (int i = 0; i < edges.size(); ++i) {
    cout << edges[i] << " ";
  }
  cout << endl;
  return 0;
}
