#include <bits/stdc++.h>
using namespace std;
vector<pair<long long int, pair<long long int, long long int> > > v[300001];
long long int dist[300001];
long long int k;
void dijkstra(long long int start, long long int wt) {
  priority_queue<pair<long long int, long long int>,
                 vector<pair<long long int, long long int> >,
                 greater<pair<long long int, long long int> > >
      pq;
  pq.push(make_pair(wt, start));
  long long int edge[300001] = {0};
  long long int inc[300001] = {0};
  long long int vis[300001] = {0};
  vector<long long int> ans;
  while (!pq.empty() && (ans.size() < k)) {
    pair<long long int, long long int> temp = pq.top();
    pq.pop();
    long long int ver = temp.second;
    long long int dis = temp.first;
    if (vis[ver] == 1)
      continue;
    else
      vis[ver] = 1;
    if (edge[ver] != 0 && inc[edge[ver]] == 0) {
      ans.push_back(edge[ver]);
      inc[edge[ver]] = 1;
      if (ans.size() == k) break;
    }
    for (long long int i = 0; i < v[ver].size(); i++) {
      if (dis + v[ver][i].first < dist[v[ver][i].second.first]) {
        dist[v[ver][i].second.first] = dis + v[ver][i].first;
        edge[v[ver][i].second.first] = v[ver][i].second.second;
        pq.push(
            make_pair(dist[v[ver][i].second.first], v[ver][i].second.first));
      }
    }
  }
  cout << ans.size() << endl;
  for (auto it = ans.begin(); (it) != ans.end(); it++) {
    long long int temp = *it;
    cout << temp << " ";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n, m;
  cin >> n >> m >> k;
  for (long long int i = 0; i < 300001; i++) {
    v[i].clear();
    dist[i] = 1e18;
  }
  long long int start = 1;
  for (long long int i = 0; i < m; i++) {
    long long int a, b, wt;
    cin >> a >> b >> wt;
    v[a].push_back(make_pair(wt, make_pair(b, i + 1)));
    v[b].push_back(make_pair(wt, make_pair(a, i + 1)));
  }
  dijkstra(start, 0);
  return 0;
}
