#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
long long min_cost[maxn];
long long nearest[maxn];
vector<pair<long long, long long>> adj[maxn];
bool visit[maxn];
bool visiet[maxn];
long long global_k;
void di(long long start_node) {
  long long count = 0;
  min_cost[start_node] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 std::greater<pair<long long, long long>>>
      qu;
  qu.push({0, start_node});
  while (!qu.empty()) {
    auto start = qu.top();
    qu.pop();
    auto start_node = start.second;
    if (visiet[start_node]) continue;
    count++;
    visiet[start_node] = true;
    for (auto i : adj[start_node]) {
      long long next_node = i.first;
      long long penaly = i.second;
      if (min_cost[next_node] > min_cost[start_node] + penaly) {
        min_cost[next_node] = min_cost[start_node] + penaly;
        nearest[next_node] = start_node;
        qu.push({min_cost[next_node], next_node});
      }
    }
    if (count > global_k + 10) return;
  }
}
vector<long long> adjj[maxn];
void rebuild_tree(int n) {
  for (int i = 1; i <= n; i++) {
    if (nearest[i] != 0 && visiet[i]) {
      adjj[nearest[i]].push_back(i);
    }
  }
}
map<pair<long long, long long>, long long> ma;
map<long long, pair<long long, long long>> mae;
long long global_m;
void bfs(int start) {
  if (global_k == 0) return;
  queue<int> qu;
  qu.push(start);
  bool visite[global_m + 10];
  memset(visite, false, sizeof(visite));
  while (!qu.empty()) {
    auto i = qu.front();
    qu.pop();
    for (auto j : adjj[i]) {
      cout << ma[{j, i}] << " ";
      global_k--;
      qu.push(j);
      visite[ma[{j, i}]] = true;
      if (global_k == 0) return;
    }
  }
  for (int j = 1; j <= global_m && global_k != 0; j++) {
    if (!visite[j]) {
      cout << j << " ";
      global_k--;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n, m, k;
  cin >> n >> m >> k;
  global_k = k;
  global_m = m;
  cout << k << endl;
  for (int i = 0; i <= n; i++) min_cost[i] = LLONG_MAX;
  for (int i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    adj[x].push_back({y, w});
    adj[y].push_back({x, w});
    ma[{x, y}] = i + 1;
    ma[{y, x}] = i + 1;
    mae[i + 1] = {x, y};
  }
  di(1);
  rebuild_tree(n);
  bfs(1);
}
