#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n, m, k;
int pre[N];
long long dis[N];
bool vis[N], mark[N];
struct Edge {
  int v, id;
  long long w;
  Edge(int v = 0, int w = 0, int id = 0) : v(v), w(w), id(id) {}
};
vector<Edge> G[N];
struct Path {
  int u;
  long long w;
  Path(int u = 0, long long w = 0) : u(u), w(w) {}
  bool operator<(const Path &p) const { return w > p.w; }
};
void dijkstra(int src) {
  memset(dis, 0x3f, sizeof(dis));
  dis[src] = 0;
  priority_queue<Path> Q;
  Q.push(Path(src, 0));
  while (!Q.empty()) {
    int u = Q.top().u;
    long long w = Q.top().w;
    Q.pop();
    if (w > dis[u]) continue;
    for (auto &e : G[u]) {
      int v = e.v;
      if (dis[v] > w + e.w) {
        dis[v] = w + e.w;
        pre[v] = e.id;
        Q.push(Path(v, dis[v]));
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0, u, v, w; i < m; i++) {
    scanf("%d%d%d", &u, &v, &w);
    G[u].emplace_back(v, w, i);
    G[v].emplace_back(u, w, i);
  }
  dijkstra(1);
  for (int i = 2; i <= n; i++) {
    mark[pre[i]] = 1;
  }
  vector<int> ans;
  queue<int> Q;
  Q.push(1);
  vis[1] = true;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (auto &e : G[u]) {
      if (vis[e.v]) continue;
      if (mark[e.id]) {
        if (ans.size() == k)
          break;
        else
          ans.push_back(e.id);
        Q.push(e.v);
        vis[e.v] = true;
      }
    }
    if (ans.size() == k) break;
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x + 1 << ' ';
  }
  puts("");
  return 0;
}
