#include <bits/stdc++.h>
using namespace std;
const int N = 3E5 + 10;
const long long INF = 1E18;
vector<pair<pair<long long, int>, int> > adj[N];
vector<int> ans;
int n, m, k;
bool vis[N];
long long d[N];
void Read_Input() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    adj[u].push_back({{w, v}, i});
    adj[v].push_back({{w, u}, i});
  }
  for (int i = 1; i <= n; i++)
    adj[i].push_back(
        pair<pair<long long, int>, int>(pair<long long, int>(0, 0), 0));
}
void Dijkstra() {
  set<pair<long long, int> > S;
  for (int i = 1; i <= n; i++) d[i] = INF;
  d[1] = 0;
  S.insert(pair<long long, int>(0, 1));
  while (S.size()) {
    int u = S.begin()->second;
    S.erase(S.begin());
    for (int i = 0; int v = adj[u][i].first.second; i++)
      if (d[v] > d[u] + adj[u][i].first.first) {
        S.erase(pair<long long, int>(d[v], v));
        d[v] = d[u] + adj[u][i].first.first;
        S.insert(pair<long long, int>(d[v], v));
      }
  }
}
void DFS(int u) {
  vis[u] = 1;
  for (int i = 0; int v = adj[u][i].first.second; i++)
    if (!vis[v] && d[u] + adj[u][i].first.first == d[v]) {
      if (ans.size() >= k) return;
      ans.push_back(adj[u][i].second);
      DFS(v);
    }
}
void PrintResult() {
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d ", ans[i]);
}
int main() {
  Read_Input();
  Dijkstra();
  DFS(1);
  PrintResult();
  return 0;
}
