#include <bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 9, MOD = 10007;
int n, m, k, p[MAX], v[MAX];
long long dist[MAX];
vector<pair<int, long long>> adj[MAX];
vector<int> tree[MAX];
vector<pair<int, int>> st;
vector<pair<int, pair<int, int>>> ham[MOD];
int fh(int x, int y) { return (x * 1LL * n * 1LL + y * 1LL) % MOD; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++) {
    int x, y;
    long long w;
    cin >> x >> y >> w;
    ham[fh(x, y)].push_back(make_pair(i, make_pair(x, y)));
    ham[fh(y, x)].push_back(make_pair(i, make_pair(y, x)));
    adj[x].push_back(make_pair(y, w));
    adj[y].push_back(make_pair(x, w));
  }
  set<pair<long long, int>> s;
  for (int i = 1; i <= n; i++) {
    dist[i] = 1e18;
  }
  dist[1] = 0;
  s.insert(make_pair(0, 1));
  while (!s.empty()) {
    long long cost = (*s.begin()).first;
    int here = (*s.begin()).second;
    s.erase(s.begin());
    if (dist[here] < cost) continue;
    for (auto e : adj[here]) {
      long long next = cost + e.second;
      int there = e.first;
      if (dist[there] > next) {
        dist[there] = next;
        p[there] = here;
        s.insert(make_pair(next, there));
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    tree[p[i]].push_back(i);
  }
  v[1] = 1;
  list<int> q;
  q.push_back(1);
  while (!q.empty()) {
    int here = q.front();
    q.pop_front();
    for (auto there : tree[here]) {
      if (v[there]) continue;
      q.push_back(there);
      v[there] = 1;
      st.push_back(make_pair(here, there));
    }
  }
  int cnt = min(k, n - 1);
  cout << cnt << '\n';
  for (int i = 0; i < cnt; i++) {
    int query = -1;
    for (auto candidate : ham[fh(st[i].first, st[i].second)]) {
      if (candidate.second == st[i]) {
        query = candidate.first;
        break;
      }
    }
    cout << query + 1 << ' ';
  }
  return 0;
}
