#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 9;
struct edge {
  int to, nex, val, eid;
} e[maxn * 10];
struct snode {
  int id, eid;
  long long dis;
  bool operator<(const snode &a) const { return dis > a.dis; }
};
vector<int> ans;
int tot = 0;
int n, m, k;
int head[maxn], pre[maxn], vis[maxn], num[maxn];
long long dis[maxn];
void addedge(int u, int v, int w, int id) {
  ++tot;
  e[tot].to = v;
  e[tot].val = w;
  e[tot].nex = head[u];
  e[tot].eid = id;
  head[u] = tot;
}
void dijkstra() {
  int s = 1;
  memset(vis, 0, sizeof(vis));
  memset(num, 0, sizeof(num));
  for (int i = 2; i <= n; i++) dis[i] = 1e18;
  dis[s] = 0;
  priority_queue<snode> pq;
  pq.push((snode){s, 0, dis[s]});
  while (!pq.empty()) {
    snode sn = pq.top();
    pq.pop();
    int u = sn.id;
    if (vis[u]) continue;
    vis[u] = 1;
    ans.push_back(sn.eid);
    if (ans.size() == k + 1) break;
    for (int i = head[u]; i; i = e[i].nex) {
      int v = e[i].to;
      if (dis[v] > sn.dis + e[i].val) {
        dis[v] = sn.dis + e[i].val;
        pq.push((snode){v, e[i].eid, dis[v]});
      }
    }
  }
}
int main() {
  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);
    addedge(u, v, w, i);
    addedge(v, u, w, i);
  }
  dijkstra();
  int cnt = min(k, (int)ans.size() - 1);
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d ", ans[i]);
}
