#include <bits/stdc++.h>
using namespace std;
int top = 0;
const int maxn = 2e6 + 5;
struct node {
  int x, y;
  long long w;
  int index;
  bool operator<(const node &b) const { return w > b.w; }
} temp, p;
struct tree {
  int x;
  int index;
  int from;
} num[maxn];
bool cmp(tree a, tree b) { return a.x < b.x; }
vector<node> e[maxn];
priority_queue<node> que;
bool vis[maxn], vis1[maxn];
void bfs(int k) {
  int i, j, u, x;
  p.x = 1;
  p.w = 0;
  p.index = 0;
  que.push(p);
  while (!que.empty()) {
    temp = que.top();
    que.pop();
    if (!vis[temp.x]) {
      vis[temp.x] = 1;
      vis1[temp.index] = 1;
      num[temp.y].x++;
      num[temp.x].x++;
      num[temp.x].from = temp.index;
      top++;
      if (top == k + 1) return;
      for (i = 0; i < e[temp.x].size(); i++) {
        u = e[temp.x][i].y;
        if (!vis[u]) {
          p.x = u;
          p.y = temp.x;
          p.w = temp.w + e[temp.x][i].w;
          p.index = e[temp.x][i].index;
          que.push(p);
        }
      }
    }
  }
}
int main() {
  int i, j, k, n, m, x, y, z, h, flag;
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++) {
    num[i].x = 0;
    num[i].index = i;
  }
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    node s;
    s.x = x;
    s.y = y;
    s.w = z;
    s.index = i;
    e[x].push_back(s);
    s.x = y;
    s.y = x;
    e[y].push_back(s);
  }
  bfs(k);
  flag = 0;
  top--;
  printf("%d\n", top);
  for (i = 1; i <= m; i++) {
    if (vis1[i]) {
      if (flag) printf(" ");
      printf("%d", i);
      flag = 1;
    }
  }
  return 0;
}
