#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
const long long inf = 0x3f3f3f3f3f3f3f3f;
struct Node {
  int y, id;
  long long val;
  Node(int b, long long c, int d) {
    y = b;
    val = c, id = d;
  }
};
vector<Node> vv[maxn];
int vis[maxn];
long long dis[maxn];
int bj[maxn];
int fa[maxn];
int n, m, k;
int ans[maxn];
struct cmp {
  bool operator()(const pair<long long, int> a, const pair<long long, int> b) {
    return a.first > b.first;
  }
};
priority_queue<pair<long long, int>, vector<pair<long long, int> >, cmp> qq;
void djs() {
  qq.push(make_pair(0, 1));
  dis[1] = 0;
  int s = 0;
  while (!qq.empty()) {
    pair<long long, int> t = qq.top();
    qq.pop();
    int x = t.second;
    if (vis[x]) continue;
    vis[x] = 1;
    for (int i = 0; i < vv[x].size(); i++) {
      Node v = vv[x][i];
      int y = v.y;
      if (vis[y]) continue;
      if (dis[y] > dis[x] + v.val) {
        dis[y] = dis[x] + v.val;
        qq.push(make_pair(dis[y], y));
        bj[y] = v.id;
        fa[y] = x;
      }
    }
  }
}
vector<int> vp[maxn];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i <= n; i++) {
    dis[i] = inf;
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    long long val;
    scanf("%d%d%lld", &x, &y, &val);
    vv[x].push_back(Node(y, val, i));
    vv[y].push_back(Node(x, val, i));
  }
  djs();
  for (int i = 1; i <= n; i++) {
    vp[fa[i]].push_back(i);
  }
  queue<int> qq;
  qq.push(1);
  int kk = 0;
  while (!qq.empty() && k > 0) {
    int x = qq.front();
    qq.pop();
    if (bj[x]) {
      k--;
      ans[kk++] = bj[x];
    }
    for (int i = 0; i < vp[x].size(); i++) {
      int v = vp[x][i];
      qq.push(v);
    }
  }
  printf("%d\n", kk);
  for (int i = 0; i < kk; i++) {
    printf("%d ", ans[i]);
  }
  printf("\n");
}
