#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int vis[N];
long long dis[N];
int pre[N];
vector<int> to[N];
struct nd {
  int v;
  long long d;
  nd() {}
  nd(int vv, long long xx) : v(vv), d(xx) {}
  bool operator<(const nd& a) const { return d > a.d; }
};
vector<nd> g[N];
map<pair<int, int>, int> mpp;
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int u, v, d;
    scanf("%d%d%d", &u, &v, &d);
    g[u].push_back(nd(v, d));
    g[v].push_back(nd(u, d));
    mpp.emplace(make_pair(u, v), i);
    mpp.emplace(make_pair(v, u), i);
  }
  for (int i = 2; i <= n; i++) dis[i] = LONG_LONG_MAX;
  dis[1] = 0;
  priority_queue<nd> q;
  q.push(nd(1, 0));
  while (!q.empty()) {
    nd top = q.top();
    q.pop();
    int v = top.v;
    if (vis[v]) continue;
    vis[v] = 1;
    for (int i = 0; i < g[v].size(); i++) {
      nd tmp = g[v][i];
      if (!vis[tmp.v] && dis[v] + tmp.d < dis[tmp.v]) {
        dis[tmp.v] = dis[v] + (long long)tmp.d;
        q.push(nd(tmp.v, dis[tmp.v]));
        pre[tmp.v] = v;
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    to[pre[i]].push_back(i);
  }
  memset(vis, 0, sizeof(vis));
  queue<pair<int, int> > q2;
  vis[1] = 1;
  for (auto x : to[1]) {
    if (k == 0) break;
    q2.push(make_pair(1, x));
    vis[x] = 1;
    k--;
  }
  vector<int> res;
  while (!q2.empty()) {
    auto it = q2.front();
    q2.pop();
    res.push_back(mpp[it]);
    int tmp = it.second;
    for (int i = 0; i < to[tmp].size(); i++) {
      if (!vis[to[tmp][i]] && k > 0) {
        vis[to[tmp][i]] = 1;
        q2.push(make_pair(tmp, to[tmp][i]));
        k--;
      }
    }
  }
  printf("%d\n", res.size());
  for (auto x : res) {
    printf("%d ", x);
  }
  return 0;
}
