#include <bits/stdc++.h>
using namespace std;
int n, m, k, fr[300005], fi[300005];
long long d[300005];
priority_queue<pair<long long, int>, vector<pair<long long, int>>,
               greater<pair<long long, int>>>
    q;
vector<pair<int, pair<int, int>>> v[300005];
vector<pair<int, int>> to[300005];
vector<int> ans;
long long ta, tc;
int tb, td, te;
void dfs(int a) {
  for (auto& p : to[a])
    if (ans.size() < k) {
      ans.push_back(p.second);
      dfs(p.first);
    }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  k = min(k, n - 1);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &td, &tb, &te);
    v[td].emplace_back(tb, make_pair(te, i));
    v[tb].emplace_back(td, make_pair(te, i));
  }
  d[1] = 1;
  q.emplace(d[1], 1);
  while (!q.empty()) {
    ta = q.top().first;
    tb = q.top().second;
    q.pop();
    if (d[tb] != ta) continue;
    for (auto& p : v[tb]) {
      tc = ta + p.second.first;
      td = p.first;
      if (d[td] == 0 || tc < d[td]) {
        d[td] = tc;
        q.emplace(d[td], td);
        fr[td] = tb;
        fi[td] = p.second.second;
      }
    }
  }
  for (int i = 2; i <= n; i++) to[fr[i]].emplace_back(i, fi[i]);
  dfs(1);
  printf("%d\n", k);
  for (int i = 0; i < ans.size(); i++)
    printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
  return 0;
}
