#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 11;
vector<pair<int, long long> > v[N];
int sz[N];
long long d[N];
int pr[N];
map<pair<int, int>, int> mt;
bool use[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    cin >> x >> y >> z;
    v[x].push_back(make_pair(y, z));
    mt[make_pair(x, y)] = i;
    mt[make_pair(y, x)] = i;
    v[y].push_back(make_pair(x, z));
  }
  set<pair<long long, int> > st;
  for (int i = 1; i <= n; i++) {
    d[i] = 2e18;
    if (i == 1) d[i] = 0;
  }
  st.insert(make_pair(0, 1));
  for (int j = 1; j <= n; j++) {
    pair<long long, int> p = *st.begin();
    st.erase(p);
    int l = p.second;
    for (int j = 0; j < v[l].size(); j++) {
      int to = v[l][j].first;
      if (d[to] > d[l] + v[l][j].second) {
        st.erase(make_pair(d[to], to));
        d[to] = d[l] + v[l][j].second;
        st.insert(make_pair(d[to], to));
        pr[to] = l;
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    sz[pr[i]]++;
    use[mt[make_pair(pr[i], i)]] = 1;
  }
  vector<int> vv;
  for (int i = 1; i <= n; i++)
    if (sz[i] == 0) vv.push_back(i);
  int t = n - 1;
  while (t > k) {
    t--;
    int l = vv.back();
    vv.pop_back();
    use[mt[make_pair(pr[l], l)]] = 0;
    sz[pr[l]]--;
    if (sz[pr[l]] == 0) vv.push_back(pr[l]);
  }
  vector<int> tt;
  for (int i = 1; i <= m; i++)
    if (use[i] == 1) tt.push_back(i);
  cout << tt.size() << endl;
  for (int j = 0; j < tt.size(); j++) cout << tt[j] << " ";
  cout << endl;
}
