#include <bits/stdc++.h>
using namespace std;
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << " " << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) return _out;
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) _in >> _i;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) return _out;
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it;
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) return _out;
  _out << "{\"" << _m.begin()->first << "\", \"" << _m.begin()->second << "\"}";
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", { \"" << _it->first << "\", \"" << _it->second << "\"}";
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) return _out;
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it)
    _out << ", (" << _it->first << ": " << _it->second << ')';
  return _out;
}
template <typename T>
void out(const vector<T> &a, int n) {
  for (int i = 1; i <= n; ++i) {
    cout << a[i] << ' ';
  }
  cout << "\n";
}
template <typename T>
void out(const vector<vector<T>> &a, int n, int m) {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cout << a[i][j] << ' ';
    }
    cout << '\n';
  }
}
struct Edge {
  long long id, from, to, w;
};
struct item {
  long long d, i;
};
struct Compare {
  bool operator()(const item &i1, const item &i2) { return i1.d > i2.d; }
};
vector<vector<int>> tree;
const long long INF = 1e16;
set<int> need;
int taken = 0, n, m, k;
map<pair<int, int>, int> mp;
void dfs(int i, int par = -1) {
  for (int j : tree[i]) {
    if (j == par) continue;
    if (taken == min(k, n - 1)) return;
    need.insert(mp[{i, j}]), taken++;
    dfs(j, i);
  }
}
void solve() {
  cin >> n >> m >> k;
  int cnt = 1;
  vector<vector<pair<int, int>>> v(n + 1);
  while (m--) {
    int x, y, w;
    cin >> x >> y >> w;
    mp[{x, y}] = mp[{y, x}] = cnt++;
    v[x].push_back({y, w}), v[y].push_back({x, w});
  }
  vector<long long> dis(n + 1, INF), par(n + 1, -1);
  priority_queue<item, vector<item>, Compare> pq;
  dis[1] = 0, pq.push(item{0, 1});
  while (!pq.empty()) {
    long long d = pq.top().d, i = pq.top().i;
    pq.pop();
    if (d > dis[i]) continue;
    for (auto [j, w] : v[i]) {
      if (dis[j] > dis[i] + w) {
        dis[j] = dis[i] + w;
        par[j] = i;
        pq.push(item{dis[j], j});
      }
    }
  }
  tree.resize(n + 1);
  for (int i = 2; i <= n; ++i) {
    tree[i].push_back(par[i]), tree[par[i]].push_back(i);
  }
  dfs(1);
  cout << need.size() << "\n";
  cout << need;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  startTime = clock();
  int T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
