#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to, cost, id;
  edge() {}
  edge(int _from, int _to, int _cost, int _id)
      : from(_from), to(_to), cost(_cost), id(_id) {}
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(9);
  const long long inf = numeric_limits<long long>::max();
  int n, m, k;
  cin >> n >> m >> k;
  vector<edge> edges(m);
  vector<vector<edge>> g(n);
  for (int i = 0; i < m; i++) {
    int x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    edges[i] = (edge){x, y, w, i};
    g[x].emplace_back(x, y, w, i);
    g[y].emplace_back(y, x, w, i);
  }
  vector<long long> dis(n, inf);
  vector<int> edge_id(n, -1);
  auto dijkstra = [&](int s) {
    priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                   greater<pair<long long, int>>>
        pq;
    dis[s] = 0;
    pq.emplace(0, s);
    while (!pq.empty()) {
      auto p = pq.top();
      pq.pop();
      int u = p.second;
      if (dis[u] < p.first) continue;
      for (edge &e : g[u]) {
        int v = e.to;
        if (dis[v] > dis[u] + e.cost) {
          dis[v] = dis[u] + e.cost;
          edge_id[v] = e.id;
          pq.emplace(dis[v], v);
        }
      }
    }
  };
  dijkstra(0);
  vector<bool> vis(m);
  vector<int> used;
  for (int i = 0; i < n; i++) {
    if (edge_id[i] >= 0) {
      used.push_back(edge_id[i]);
      vis[edge_id[i]] = true;
    }
  }
  if ((int)used.size() <= k) {
    cout << k << '\n';
    for (int x : used) {
      cout << x + 1 << ' ';
    }
    k -= (int)used.size();
    for (int i = 0; i < m && k; i++) {
      if (vis[i]) continue;
      k--;
      cout << i + 1 << ' ';
    }
    cout << '\n';
  } else {
    vector<vector<pair<int, int>>> tree(n);
    for (int x : used) {
      int u = edges[x].from, v = edges[x].to;
      tree[u].emplace_back(v, x);
      tree[v].emplace_back(u, x);
    }
    vector<int> ans;
    function<void(int, int)> dfs = [&](int u, int fa) {
      if ((int)ans.size() >= k) return;
      for (auto e : tree[u]) {
        int v = e.first;
        if (v == fa) continue;
        if ((int)ans.size() < k) ans.push_back(e.second);
        dfs(v, u);
      }
    };
    dfs(0, -1);
    cout << (int)ans.size() << '\n';
    for (int x : ans) {
      cout << x + 1 << ' ';
    }
    cout << '\n';
  }
  return 0;
}
