#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int maxm = 1e6 + 10;
const long long INF = 1e16;
const int inf = 0x3f3f3f3f;
const long long mod = 19260817;
const int maxblock = sqrt(maxn) + 10;
struct Edge {
  int u, v;
  long long w;
  int next;
} edge[maxm];
int head[maxn];
int tot = 0;
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
void addedge(int u, int v, long long w) {
  edge[tot] = Edge{u, v, w, head[u]};
  head[u] = tot++;
}
bool vis[maxn];
long long d[maxn];
struct E {
  int v;
  long long w;
  bool operator<(const E &_) const { return w > _.w; }
};
void dij(int s, int n) {
  for (int i = 1; i <= n; i++) {
    d[i] = INF;
    vis[i] = 0;
  }
  vis[s] = 1;
  d[s] = 0;
  priority_queue<E> q;
  for (int i = head[s]; i + 1; i = edge[i].next) {
    q.push((E){edge[i].v, edge[i].w});
  }
  while (!q.empty()) {
    E tmp = q.top();
    q.pop();
    int v = tmp.v;
    long long w = tmp.w;
    if (vis[tmp.v]) continue;
    d[v] = w;
    vis[v] = 1;
    for (int i = head[v]; i + 1; i = edge[i].next) {
      if (!vis[edge[i].v]) q.push((E){edge[i].v, d[v] + edge[i].w});
    }
  }
}
vector<int> g[maxn];
struct node {
  int u, v;
  long long w;
  void input() { scanf("%d %d %lld", &u, &v, &w); }
} a[maxm];
int n, m, k;
bool VIS[maxn];
map<pair<int, int>, int> ma;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  init();
  for (int i = 1; i <= m; i++) a[i].input();
  for (int i = 1; i <= m; i++) {
    addedge(a[i].u, a[i].v, a[i].w);
    addedge(a[i].v, a[i].u, a[i].w);
  }
  dij(1, n);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int flag = 0;
    if (d[a[i].u] + a[i].w == d[a[i].v]) {
      flag = 1;
      g[a[i].u].push_back(a[i].v);
    }
    if (d[a[i].v] + a[i].w == d[a[i].u]) {
      flag = 1;
      g[a[i].v].push_back(a[i].u);
    }
    if (flag) cnt++;
  }
  if (cnt <= k) {
    for (int i = 1; i <= m; i++) {
      if (d[a[i].u] + a[i].w == d[a[i].v] || d[a[i].v] + a[i].w == d[a[i].u]) {
        VIS[i] = 1;
      }
    }
    int remain = k - cnt;
    for (int i = 1; i <= m; i++) {
      if (remain == 0) break;
      if (!VIS[i]) {
        VIS[i] = 1;
        remain--;
      }
    }
  } else {
    for (int i = 1; i <= m; i++) {
      ma.insert(make_pair(make_pair(a[i].u, a[i].v), i));
      ma.insert(make_pair(make_pair(a[i].v, a[i].u), i));
    }
    queue<int> q;
    q.push(1);
    memset(vis, 0, sizeof(vis));
    int cnt = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i];
        if (vis[v]) continue;
        if (cnt < k) {
          cnt++;
          VIS[ma[make_pair(u, v)]] = 1;
        }
        vis[v] = 1;
        q.push(v);
      }
    }
  }
  int num = 0;
  for (int i = 1; i <= m; i++) num += VIS[i];
  printf("%d\n", num);
  for (int i = 1; i <= m; i++) {
    if (VIS[i]) printf("%d ", i);
  }
  printf("\n");
  return 0;
}
