#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18 + 5;
const int N = 3e5 + 5;
vector<long long> edge[N];
vector<long long> cost[N];
vector<long long> id[N];
bool vis[N];
int rnk[N];
int al_id[N];
long long dis[N];
void magic(int n, int source) {
  for (int i = 1; i <= n; i++) {
    dis[i] = inf;
  }
  dis[source] = 0;
  priority_queue<pair<long long, long long> > pq;
  pq.push({0, source});
  vector<long long> used;
  while (not pq.empty()) {
    pair<long long, long long> cur = pq.top();
    pq.pop();
    long long cur_node = cur.second;
    long long cur_dis = -cur.first;
    if (vis[cur_node]) continue;
    vis[cur_node] = 1;
    used.push_back(al_id[cur_node]);
    for (int i = 0; i < edge[cur_node].size(); i++) {
      long long v = edge[cur_node][i];
      long long new_cost = cur_dis + cost[cur_node][i];
      long long iD = id[cur_node][i];
      if (vis[v]) continue;
      if (new_cost < dis[v]) {
        dis[v] = new_cost;
        al_id[v] = iD;
        pq.push({-new_cost, v});
      }
    }
  }
  for (int i = 0; i < used.size(); i++) {
    rnk[used[i]] = i;
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    edge[u].push_back(v);
    id[u].push_back(i);
    cost[u].push_back(w);
    edge[v].push_back(u);
    id[v].push_back(i);
    cost[v].push_back(w);
    rnk[i] = N;
  }
  magic(n, 1);
  vector<pair<long long, long long> > ans;
  for (int i = 1; i <= m; i++) {
    ans.push_back({rnk[i], i});
  }
  sort(ans.begin(), ans.end());
  cout << k << "\n";
  for (int i = 0; i < k; i++) {
    cout << ans[i].second << " ";
  }
  return 0;
}
