#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<pair<pair<int, int>, int> > E[300007];
bool vis[300007];
long long dis[300007];
bool ans[300007];
int pre[300007];
priority_queue<pair<long long, int> > q;
int main() {
  int u, v, c;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    E[u].push_back(make_pair(make_pair(v, c), i));
    E[v].push_back(make_pair(make_pair(u, c), i));
  }
  memset(vis, false, sizeof(vis));
  memset(dis, 0x3f, sizeof(dis));
  memset(ans, false, sizeof(ans));
  dis[1] = 0LL;
  q.push(make_pair(0, 1));
  int K = min(k + 1, n);
  while (K--) {
    while (vis[q.top().second]) q.pop();
    u = q.top().second;
    q.pop();
    vis[u] = true;
    ans[pre[u]] = true;
    for (int i = 0; i < E[u].size(); i++) {
      int v = E[u][i].first.first;
      if (vis[v]) continue;
      if (dis[v] <= dis[u] + E[u][i].first.second) continue;
      dis[v] = dis[u] + E[u][i].first.second;
      q.push(make_pair(-dis[v], v));
      pre[v] = E[u][i].second;
    }
  }
  K = min(k, n - 1);
  printf("%d\n", K);
  for (int i = 1; i <= m; i++)
    if (ans[i]) printf("%d ", i);
  printf("\n");
  return 0;
}
