#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(long long n, long long i) {
  return n & ((long long)1 << i);
}
inline long long setBit(long long n, long long i) {
  return n | ((long long)1 << i);
  ;
}
inline long long resetBit(long long n, long long i) {
  return n & (~((long long)1 << i));
}
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 998244353;
  (a < 0) && (a += 998244353);
}
inline long long modMul(long long a, long long b) {
  a %= 998244353, b %= 998244353;
  normal(a), normal(b);
  return (a * b) % 998244353;
}
inline long long modAdd(long long a, long long b) {
  a %= 998244353, b %= 998244353;
  normal(a), normal(b);
  return (a + b) % 998244353;
}
inline long long modSub(long long a, long long b) {
  a %= 998244353, b %= 998244353;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 998244353 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
const long long N = 3e5 + 10;
vector<pair<long long, long long> > g1[N];
vector<long long> g[N];
long long n, m, k, e, num;
map<pair<long long, long long>, long long> m1;
bool visited[N];
void dfs(long long v, long long u) {
  for (long long i = 0; i < (long long)((g[v]).size()); i++) {
    if (u != g[v][i] && e) {
      long long to = g[v][i];
      dfs(to, v);
    }
  }
  num++;
  if (num <= e && u != 0) {
    m1[{u, v}] = 0;
    m1[{v, u}] = 0;
  }
}
void prism(long long x) {
  priority_queue<pair<long long, pair<long long, long long> >,
                 vector<pair<long long, pair<long long, long long> > >,
                 greater<pair<long long, pair<long long, long long> > > >
      q;
  q.push({(long long)0, {x, x}});
  while (!q.empty()) {
    pair<long long, pair<long long, long long> > p = q.top();
    q.pop();
    if (visited[p.second.first]) continue;
    visited[p.second.first] = true;
    if (p.second.first != 1) {
      m1[{p.second.second, p.second.first}] = 1;
      m1[{p.second.first, p.second.second}] = 1;
      g[p.second.second].push_back(p.second.first);
      g[p.second.first].push_back(p.second.second);
    }
    for (long long i = 0; i < (long long)((g1[p.second.first]).size()); i++) {
      if (!visited[g1[p.second.first][i].second]) {
        g1[p.second.first][i].first += p.first;
        q.push({g1[p.second.first][i].first,
                {g1[p.second.first][i].second, p.second.first}});
      }
    }
  }
}
void solve() {
  cin >> n >> m >> k;
  pair<long long, long long> p[m];
  vector<long long> ans;
  for (long long i = 0; i < m; i++) {
    long long x, y, w;
    cin >> x >> y >> w;
    p[i].first = x, p[i].second = y;
    g1[x].push_back({w, y});
    g1[y].push_back({w, x});
  }
  prism(1);
  for (long long i = 0; i < m; i++) {
    if (m1[{p[i].first, p[i].second}]) {
      ans.push_back(i + 1);
    }
  }
  cout << min(n - 1, k) << endl;
  if (k >= n - 1) {
    for (long long i = 0; i < n - 1; i++) {
      cout << ans[i] << " ";
    }
  } else {
    e = n - 1 - k;
    dfs(1, 0);
    for (long long i = 0; i < m; i++) {
      if (m1[{p[i].first, p[i].second}]) {
        cout << i + 1 << " ";
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
