#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
long long max3(long long x, long long y, long long z) {
  return max(max(x, y), z);
}
long long min3(long long x, long long y, long long z) {
  return min(min(x, y), z);
}
const long long N = 3e5 + 10, M = 2e5 + 10, M2 = 1e6 + 10, mod = 1e9 + 7,
                inf = 1e17 + 10;
const long long INF = 1e9 + 7;
void add(long long& a, long long b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
long long X[] = {0, 1, 0, -1};
long long Y[] = {-1, 0, 1, 0};
long long power(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n = n / 2;
  }
  return result;
}
long long n, m, k;
vector<pair<long long, pair<long long, long long>>> g[N];
set<pair<long long, long long>> q;
long long cnt;
vector<long long> ans;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    x--;
    y--;
    g[x].push_back({y, {w, i}});
    g[y].push_back({x, {w, i}});
  }
  vector<long long> d(N, inf);
  vector<long long> last(N, -1);
  d[0] = 0;
  q.insert({0, 0});
  while (!q.empty() && cnt < k) {
    auto z = *q.begin();
    q.erase(q.begin());
    long long k = z.second;
    if (last[k] != -1) {
      cnt++;
      ans.push_back(last[k]);
    }
    for (auto y : g[k]) {
      long long to = y.first;
      long long w = y.second.first;
      long long idx = y.second.second;
      if (d[to] > d[k] + w) {
        q.erase(make_pair(d[to], to));
        d[to] = d[k] + w;
        last[to] = idx;
        q.insert(make_pair(d[to], to));
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto u : ans) cout << u + 1 << " ";
  return 0;
}
