#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
const long long INF = 1e18 + 7;
long long dp[N];
int edge[N];
int n, m, k;
vector<pair<int, pair<int, int> > > g[N];
vector<int> ans;
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    g[a].push_back(make_pair(b, make_pair(c, i)));
    g[b].push_back(make_pair(a, make_pair(c, i)));
  }
  priority_queue<pair<long long, int> > pq;
  pq.push(make_pair(0, 1));
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  dp[1] = 0;
  k++;
  while (!pq.empty()) {
    int v = pq.top().second;
    long long d = -pq.top().first;
    pq.pop();
    if (d > dp[v] || !k) continue;
    k--;
    if (v != 1) ans.push_back(edge[v]);
    for (auto to : g[v]) {
      if (dp[to.first] > d + (to.second.first * 1LL)) {
        dp[to.first] = d + (to.second.first * 1LL);
        pq.push(make_pair(-dp[to.first], to.first));
        edge[to.first] = to.second.second;
      }
    }
  }
  printf("%d\n", ans.size());
  for (int out : ans) printf("%d ", out);
}
