#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 61;
const int maxn = 300000 + 10;
const int MAXN = 600000 + 10;
struct Edge {
  long long from, to, dis, next, id;
} edge[MAXN];
struct Node {
  long long to;
  long long dis, pre;
  bool operator<(const Node &a) const { return dis > a.dis; }
};
long long n, m, k, e, d[maxn], vis[maxn], head[maxn];
vector<long long> ans;
void add_edge(long long a, long long b, long long c, long long d) {
  edge[e].from = a;
  edge[e].to = b;
  edge[e].dis = c;
  edge[e].id = d;
  edge[e].next = head[a];
  head[a] = e++;
}
void dijkstra() {
  priority_queue<Node> pq;
  pq.push(Node{1, 0, -1});
  d[1] = 0;
  while (!pq.empty()) {
    if (ans.size() == min(n - 1, k)) return;
    Node f = pq.top();
    pq.pop();
    if (vis[f.to]) continue;
    vis[f.to] = 1;
    if (f.pre != -1) ans.push_back(f.pre);
    for (int i = head[f.to]; i != -1; i = edge[i].next) {
      long long next = edge[i].to;
      long long dis = edge[i].dis;
      if (d[next] > d[f.to] + dis) {
        d[next] = d[f.to] + dis;
        pq.push(Node{next, d[next], edge[i].id});
      }
    }
  }
}
void init() {
  e = 0;
  for (int i = 0; i <= n; i++) {
    head[i] = -1;
    d[i] = inf;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long a, b, c;
  cin >> n >> m >> k;
  init();
  for (int i = 1; i <= m; i++) {
    cin >> a >> b >> c;
    add_edge(a, b, c, i);
    add_edge(b, a, c, i);
  }
  dijkstra();
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  if (ans.size() > 0) cout << endl;
}
