#include <bits/stdc++.h>
using namespace std;
const int MAX = 300005;
const long long INF = 1e18;
struct s {
  long long u, w, idx;
  s(long long _u, long long _w, long long _idx) {
    u = _u;
    w = _w;
    idx = _idx;
  }
};
bool operator<(s A, s B) { return A.w < B.w; }
long long dis[MAX + 9], dis2[MAX + 9];
vector<s> edges[MAX + 9];
vector<int> ans;
int n, m, k;
bool vis[MAX + 9];
void Dijkstra() {
  priority_queue<pair<long long, long long> > pq;
  dis[1] = 0;
  pq.push(make_pair(0, 1));
  while (!pq.empty()) {
    long long u = pq.top().second;
    long long now = -pq.top().first;
    pq.pop();
    if (now > dis[u]) continue;
    for (int i = 0; i < edges[u].size(); i++) {
      long long v = edges[u][i].u;
      long long c = edges[u][i].w;
      if (dis[v] > dis[u] + c) {
        dis[v] = dis[u] + c;
        pq.emplace(make_pair(-dis[v], v));
      }
    }
  }
}
void Dijkstra2() {
  priority_queue<pair<long long, long long> > pq;
  dis2[1] = 0;
  pq.push(make_pair(0, 1));
  while (!pq.empty()) {
    long long u = pq.top().second;
    long long now = -pq.top().first;
    pq.pop();
    if (k <= 0) break;
    if (now > dis2[u]) continue;
    for (int i = 0; i < edges[u].size(); i++) {
      long long v = edges[u][i].u;
      long long c = edges[u][i].w;
      long long id = edges[u][i].idx;
      if (dis[v] == dis2[u] + c && k > 0 && vis[v] == false) {
        vis[v] = true;
        dis2[v] = dis2[u] + c;
        k--;
        ans.push_back(id);
        if (k <= 0) break;
        pq.emplace(make_pair(-dis2[v], v));
      }
    }
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    long long in1, in2, in3;
    cin >> in1 >> in2 >> in3;
    edges[in1].emplace_back(s(in2, in3, i + 1));
    edges[in2].emplace_back(s(in1, in3, i + 1));
  }
  for (int i = 0; i <= n; i++) {
    dis[i] = dis2[i] = INF;
  }
  memset(vis, false, sizeof(vis));
  Dijkstra();
  Dijkstra2();
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
