#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long cc = getc(stdin);
  for (; cc < '0' || cc > '9';) cc = getc(stdin);
  long long ret = 0;
  for (; cc >= '0' && cc <= '9';) {
    ret = ret * 10 + cc - '0';
    cc = getc(stdin);
  }
  return ret;
}
long long power(long long num, long long g) {
  if (g == 0) return 1;
  if (g % 2 == 1)
    return (num * power((num * num) % 1000000007, g / 2)) % 1000000007;
  return power((num * num) % 1000000007, g / 2);
}
bool visit[300005];
vector<pair<long long, long long> > vec1[300005];
vector<long long> vec[300005];
long long parent[300005];
long long a[300005];
int qw;
map<pair<long long, long long>, long long> mp1;
void dfs(int index) {
  visit[index] = true;
  for (int i = 0; i < vec[index].size(); i++) {
    if (visit[vec[index][i]]) continue;
    dfs(vec[index][i]);
    if (qw == 0) return;
    qw--;
    mp1[make_pair(index, vec[index][i])] = 0;
    mp1[make_pair(vec[index][i], index)] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  pair<pair<long long, long long>, pair<long long, long long> > pa[m + 1];
  for (long long i = 0; i < n; i++)
    parent[i + 1] = -1, a[i + 1] = LONG_LONG_MAX;
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    vec1[u].push_back(make_pair(w, v));
    vec1[v].push_back(make_pair(w, u));
    pa[i] = make_pair(make_pair(w, i + 1), make_pair(u, v));
    mp1[make_pair(u, v)] = 0;
    mp1[make_pair(v, u)] = 0;
  }
  a[1] = 0;
  memset(visit, false, sizeof(visit));
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      pq;
  pq.push(make_pair(0, 1));
  parent[1] = 0;
  while (!pq.empty()) {
    long long u = pq.top().second;
    long long w = pq.top().first;
    pq.pop();
    if (visit[u] == false) {
      visit[u] = true;
      mp1[make_pair(u, parent[u])] = 1;
      mp1[make_pair(parent[u], u)] = 1;
    } else
      continue;
    for (int i = 0; i < vec1[u].size(); i++) {
      if (visit[vec1[u][i].second]) continue;
      if (w + vec1[u][i].first < a[vec1[u][i].second]) {
        a[vec1[u][i].second] = w + vec1[u][i].first;
        parent[vec1[u][i].second] = u;
        pq.push(make_pair(a[vec1[u][i].second], vec1[u][i].second));
      }
    }
  }
  if (n - 1 <= k) {
    cout << n - 1 << endl;
    for (long long i = 0; i < m; i++) {
      if (mp1[pa[i].second] == 1) cout << i + 1 << " ";
    }
  } else {
    for (long long i = 0; i < m; i++) {
      visit[i + 1] = false;
      if (mp1[pa[i].second] == 0) continue;
      vec[pa[i].second.first].push_back(pa[i].second.second);
      vec[pa[i].second.second].push_back(pa[i].second.first);
    }
    visit[n] = false;
    int wer = 1;
    cout << k << endl;
    qw = n - 1 - k;
    dfs(1);
    for (long long i = 0; i < m; i++) {
      if (mp1[pa[i].second] == 1) cout << i + 1 << " ";
    }
  }
  return 0;
}
