#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long INF = 0x7fffffffffffffff;
inline int read_int() {
  char c;
  int ret = 0, sgn = 1;
  do {
    c = getchar();
  } while ((c < '0' || c > '9') && c != '-');
  if (c == '-')
    sgn = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  return sgn * ret;
}
inline long long read_ll() {
  char c;
  long long ret = 0, sgn = 1;
  do {
    c = getchar();
  } while ((c < '0' || c > '9') && c != '-');
  if (c == '-')
    sgn = -1;
  else
    ret = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  return sgn * ret;
}
struct edge {
  edge() = default;
  edge(int _to, int _weight, int _id) : to(_to), weight(_weight), id(_id) {}
  int to, weight, id;
};
long long dis[300000 + 5];
int n, m, k, from, to, weight, cnt;
bool vis[300000 + 5];
vector<edge> G[300000 + 5];
vector<int> res;
struct cmp {
  bool operator()(int a, int b) { return dis[a] > dis[b]; }
};
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    q;
priority_queue<int, vector<int>, cmp> pq;
void Dijkstra() {
  for (int i = 1; i <= n; ++i) dis[i] = INF;
  dis[1] = 0;
  q.push(pair<int, int>(0, 1));
  while (!q.empty()) {
    pair<int, int> now = q.top();
    q.pop();
    int v = now.second;
    if (dis[v] < now.first) continue;
    for (int i = 0; i < G[v].size(); ++i) {
      edge& e = G[v][i];
      if (dis[e.to] > dis[v] + e.weight) {
        dis[e.to] = dis[v] + e.weight;
        q.push(pair<int, int>(dis[e.to], e.to));
      }
    }
  }
}
int main(void) {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %d", &from, &to, &weight);
    G[from].push_back(edge(to, weight, i));
    G[to].push_back(edge(from, weight, i));
  }
  Dijkstra();
  pq.push(1);
  vis[1] = true;
  while (!pq.empty()) {
    int now = pq.top();
    pq.pop();
    if (cnt == k) break;
    for (int i = 0; i < G[now].size(); ++i) {
      if (cnt == k) break;
      edge& e = G[now][i];
      if (dis[now] + e.weight == dis[e.to] && !vis[e.to]) {
        vis[e.to] = true;
        pq.push(e.to);
        res.push_back(e.id);
        cnt++;
      }
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); ++i) cout << res[i] << " ";
  cout << endl;
  return 0;
}
