#include <bits/stdc++.h>
using namespace std;
const int maxn = 300100;
int n, m, k;
struct edge {
 public:
  long long x, value, index;
};
vector<edge> g[maxn];
long long dist[maxn], parent[maxn];
bool visited[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  long long x, y, w;
  for (int i = 0; i < m; i++) {
    cin >> x >> y >> w;
    g[x].push_back({y, w, i + 1});
    g[y].push_back({x, w, i + 1});
  }
  for (int i = 2; i <= n; i++) dist[i] = LLONG_MAX;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(make_pair(0LL, 1LL));
  dist[1] = 0LL;
  int cnt = 0;
  while (!pq.empty()) {
    long long curr = pq.top().second;
    pq.pop();
    if (visited[curr]) continue;
    visited[curr] = true;
    cnt++;
    if (cnt == min(k + 1, n)) break;
    for (auto i : g[curr]) {
      if (!visited[i.x] && dist[i.x] > dist[curr] + i.value) {
        dist[i.x] = dist[curr] + i.value;
        parent[i.x] = i.index;
        pq.push(make_pair(dist[i.x], i.x));
      }
    }
  }
  vector<int> result;
  for (int i = 2; i <= n; i++) {
    if (visited[i]) {
      result.push_back(parent[i]);
    }
  }
  cout << result.size() << "\n";
  for (int i : result) {
    cout << i << " ";
  }
  cout << "\n";
  return 0;
}
