#include <bits/stdc++.h>
using namespace std;
long long modx(long long Base, long long exponent) {
  long long ans = 1;
  if (Base == 1) return Base;
  while (exponent) {
    if (exponent & 1) ans = (ans * Base) % 1000000007LL;
    Base = (Base * Base) % 1000000007LL;
    exponent = exponent >> 1;
  }
  return ans;
}
long long inmodx(long long num) { return (modx(num, 1000000007LL - 2LL)); }
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.second < b.first.second) return 1;
  if (a.first.second > b.first.second) return 0;
  if (a.first.first <= b.first.first) return 1;
  return 0;
}
const int N = (3e5) + 9;
const int M = (N << 2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 450;
vector<int> v[N];
pair<pair<int, int>, long long> edge[N];
bool vis[N];
vector<int> ans;
priority_queue<pair<long long, pair<int, int> > > pq;
int neighbour(int x, int e) {
  return ((x == edge[e].first.first) ? edge[e].first.second
                                     : edge[e].first.first);
}
void solve() {
  int n, m, k, i, a, b;
  long long c;
  pair<long long, pair<int, int> > z;
  cin >> n >> m >> k;
  for (i = (1); i < (m + 1); i++) {
    cin >> a >> b >> c;
    edge[i] = {{a, b}, c};
    v[a].push_back(i);
    v[b].push_back(i);
  }
  pq.push(make_pair(-0, make_pair(1, 0)));
  while (!pq.empty()) {
    z = pq.top();
    pq.pop();
    if (vis[z.second.first]) continue;
    vis[z.second.first] = 1;
    if (z.second.second > 0) ans.push_back(z.second.second);
    for (auto e : v[z.second.first]) {
      a = neighbour(z.second.first, e);
      pq.push(make_pair(z.first - edge[e].second, make_pair(a, e)));
    }
  }
  cout << min(k, (int)((ans).size())) << '\n';
  for (i = (0); i < ((int)((ans).size())); i++) {
    if (i >= k) break;
    cout << ans[i] << " ";
  }
  cout << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  clock_t clk;
  clk = clock();
  int t = 1, cs;
  cout << fixed << setprecision(9);
  for (cs = (1); cs < (t + 1); cs++) {
    solve();
  }
  clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk) / CLOCKS_PER_SEC
       << "\n";
  return 0;
}
