#include <bits/stdc++.h>
using namespace std;
struct E {
  int num;
  long long w;
};
struct A {
  int x;
  long long d;
  bool operator<(const A &p) const { return d > p.d; }
};
vector<pair<int, E>> v[300001];
priority_queue<A> q;
long long d[300001];
int idx[300001];
bool c[300001];
vector<int> ans;
const long long MAX = INT64_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  if (!k) {
    cout << 0;
    return 0;
  }
  for (int i = 1; i <= n; i++) d[i] = MAX;
  int x, y;
  long long z;
  for (int i = 1; i <= m; i++) {
    cin >> x >> y >> z;
    v[x].push_back({y, {i, z}});
    v[y].push_back({x, {i, z}});
  }
  d[1] = 0;
  q.push({1, 0});
  int count = 0;
  while (!q.empty()) {
    x = q.top().x;
    q.pop();
    if (c[x]) continue;
    c[x] = true;
    if (x != 1) {
      count++;
      ans.push_back(idx[x]);
      if (count == k || count == n - 1) {
        cout << count << '\n';
        for (int i = 0; i < count; i++) {
          cout << ans[i] << ' ';
        }
        return 0;
      }
    }
    int size = v[x].size();
    for (int i = 0; i < size; i++) {
      if (!c[v[x][i].first]) {
        if (d[v[x][i].first] > d[x] + v[x][i].second.w) {
          idx[v[x][i].first] = v[x][i].second.num;
          d[v[x][i].first] = d[x] + v[x][i].second.w;
          q.push({v[x][i].first, d[v[x][i].first]});
        }
      }
    }
  }
}
