#include <bits/stdc++.h>
using namespace std;
const long long N = 3e5 + 15, INF = 1e18;
long long n, m, k, dist[N], pa[N];
bool good[N], vis[N];
vector<long long> res, son;
vector<pair<long long, pair<long long, long long>>> g[N];
vector<pair<long long, pair<long long, long long>>> e;
priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
               greater<pair<long long, long long>>>
    pq;
void dijkstra(long long src) {
  long long u, v;
  long long w;
  for (long long i = 0; i < n; i++) dist[i] = INF;
  dist[src] = 0;
  pq.push({0ll, src});
  while (!pq.empty()) {
    w = pq.top().first;
    u = pq.top().second;
    pq.pop();
    if (w <= dist[u]) {
      for (auto p : g[u]) {
        v = p.second.first, w = p.first;
        if (dist[v] > dist[u] + w) {
          pa[v] = u;
          dist[v] = dist[u] + w;
          pq.push({dist[v], v});
        }
      }
    }
  }
}
void build(long long pos) {
  if (vis[pos]) return;
  vis[pos] = 1;
  for (auto it : g[pos]) {
    if (!k) return;
    if (pa[it.second.first] == pos) {
      good[it.second.second] = 1;
      k--;
      build(it.second.first);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a].push_back({c, {b, i}});
    g[b].push_back({c, {a, i}});
    e.push_back({c, {min(a, b), max(a, b)}});
  }
  pa[0] = -1;
  dijkstra(0);
  build(0);
  for (long long i = 0; i < m; i++) {
    if (!k) break;
    if (!good[i]) good[i] = 1, k--;
  }
  vector<int> res;
  for (long long i = 0; i < m; i++)
    if (good[i]) res.push_back(i + 1);
  cout << res.size() << endl;
  for (auto i : res) cout << i << " ";
  cout << endl;
  ;
}
