#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x > y ? x : y; }
long long min(long long x, long long y) { return x < y ? x : y; }
void _(long long& a, long long b) {
  a = (a % 1000000007 + b % 1000000007) % 1000000007;
  a = (a + 1000000007) % 1000000007;
}
long long cl(long long a, long long b) { return (a / b) + (!(!(a % b))); }
class node {
 public:
  long long val, ind, wei;
  node(long long val, long long ind, long long wei) {
    this->val = val;
    this->ind = ind;
    this->wei = wei;
  }
};
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<node> e[n];
  for (long long i = 0; i < m; ++i) {
    long long u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    e[u].push_back(node(v, i, w));
    e[v].push_back(node(u, i, w));
  }
  set<pair<long long, long long> > s;
  s.insert({0, 0});
  bool vis[n];
  memset(vis, 0, sizeof(vis));
  long long dis[n];
  for (long long i = 0; i < n; ++i) {
    dis[i] = 1e17;
  }
  long long par[n];
  memset(par, -1, sizeof(par));
  dis[0] = 0;
  vector<long long> ans;
  while (!s.empty()) {
    pair<long long, long long> p = *s.begin();
    s.erase(s.begin());
    vis[p.second] = 1;
    if (par[p.second] != -1) ans.push_back(par[p.second]);
    for (auto j : e[p.second]) {
      if (!vis[j.val]) {
        s.erase({dis[j.val], j.val});
        if (dis[j.val] > dis[p.second] + j.wei) {
          dis[j.val] = dis[p.second] + j.wei;
          par[j.val] = j.ind;
        }
        s.insert({dis[j.val], j.val});
      }
    }
  }
  cout << min(n - 1, k) << "\n";
  for (long long i = 0; i < min(n - 1, k); ++i) {
    cout << ans[i] + 1 << " ";
  }
}
