#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 7;
const long long inf = (long long)1e18 + 7;
int n, m, k;
vector<pair<int, int> > gr[N];
long long d[N];
map<pair<int, int>, int> mp;
void dij() {
  for (int i = 1; i <= n; i++) {
    d[i] = inf;
  }
  d[1] = 0;
  priority_queue<pair<long long, int> > q;
  q.push({0, 1});
  while (!q.empty()) {
    pair<long long, int> v = q.top();
    q.pop();
    if (-v.first > d[v.second]) continue;
    for (pair<int, int> tto : gr[v.second]) {
      int to = tto.first;
      int cost = tto.second;
      if (d[v.second] + cost < d[to]) {
        d[to] = d[v.second] + cost;
        q.push({-d[to], to});
      }
    }
  }
}
int used[N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    gr[u].push_back({v, w});
    gr[v].push_back({u, w});
    mp[{u, v}] = mp[{v, u}] = i;
  }
  dij();
  queue<int> q;
  q.push(1);
  vector<int> ans;
  used[1] = 1;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (pair<int, int> tto : gr[v]) {
      int to = tto.first;
      int cost = tto.second;
      if (used[to]) continue;
      if (d[v] + cost == d[to]) {
        ans.push_back(mp[{v, to}]);
        used[to] = 1;
        q.push(to);
      }
    }
  }
  k = min(k, (int)ans.size());
  cout << k << '\n';
  for (int i = 0; i < k; i++) {
    cout << ans[i] << ' ';
  }
}
