#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3fLL;
vector<pair<int, int> > mp[300005];
vector<int> id[300005];
long long d[300005];
int pre[300005];
int n, m, k, x, y, w;
priority_queue<pair<long long, int>, vector<pair<long long, int> >,
               greater<pair<long long, int> > >
    pq;
bool f[300005];
void dijkstra(int s) {
  int now, cnt;
  long long nowd;
  cnt = 0;
  for (int i = 1; i <= n; i++) d[i] = inf;
  d[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    nowd = pq.top().first;
    now = pq.top().second;
    pq.pop();
    if (d[now] != nowd) continue;
    f[now] = true;
    cnt++;
    if (cnt == k + 1) break;
    for (int i = 0; i < mp[now].size(); i++)
      if (d[now] + mp[now][i].second < d[mp[now][i].first]) {
        d[mp[now][i].first] = d[now] + mp[now][i].second;
        pq.push(make_pair(d[mp[now][i].first], mp[now][i].first));
        pre[mp[now][i].first] = id[now][i];
      }
  }
}
int main() {
  int cnt, now, ans, cntt;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &w);
    mp[x].push_back(make_pair(y, w));
    id[x].push_back(i + 1);
    mp[y].push_back(make_pair(x, w));
    id[y].push_back(i + 1);
  }
  dijkstra(1);
  printf("%d\n", min(k, n - 1));
  cntt = 0;
  for (int i = 2; i <= n; i++)
    if (f[i])
      if (cntt != min(k, n - 1) - 1)
        printf("%d ", pre[i]);
      else
        printf("%d\n", pre[i]);
  return 0;
}
