#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 20;
const long long Inf = 2e18;
long long n, m, k;
long long mark[N], dis[N];
vector<pair<pair<long long, long long>, long long> > g[N];
vector<pair<long long, long long> > G[N];
vector<long long> ans;
void dfs(long long u) {
  mark[u] = 1;
  if (ans.size() == k) return;
  for (auto h : G[u])
    if (!mark[h.first] && ans.size() < k) ans.push_back(h.second), dfs(h.first);
  if (ans.size() == k) return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long i, j;
  cin >> n >> m >> k;
  for (i = 0; i < m; ++i) {
    long long f, t, w;
    cin >> f >> t >> w;
    --t, --f;
    g[f].push_back({{w, i + 1}, t});
    g[t].push_back({{w, i + 1}, f});
  }
  set<pair<long long, long long> > st;
  dis[0] = 0;
  for (i = 0; i < n; ++i) {
    if (i) dis[i] = Inf;
    st.insert({dis[i], i});
  }
  while (st.size()) {
    long long a = st.begin()->first;
    long long b = st.begin()->second;
    st.erase(st.begin());
    mark[b] = 1;
    for (auto h : g[b]) {
      if (a + h.first.first < dis[h.second] && !mark[h.second]) {
        st.erase({dis[h.second], h.second});
        dis[h.second] = a + h.first.first;
        st.insert({a + h.first.first, h.second});
      }
    }
  }
  for (i = 0; i < n; ++i) {
    for (auto h : g[i]) {
      if (dis[i] + h.first.first == dis[h.second]) {
        G[i].push_back({h.second, h.first.second});
      }
    }
  }
  fill(mark, mark + N, 0LL);
  dfs(0LL);
  cout << ans.size() << '\n';
  for (auto h : ans) cout << h << ' ';
  return 0;
}
