#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int mod = 1e9 + 7;
int parent[N], vis[N];
long long int dist[N];
vector<pair<int, int> > v[N];
vector<int> tree[N], ans;
map<pair<int, int>, int> mp;
inline void bfs(int k) {
  queue<int> q;
  q.push(1);
  int edges(0);
  vis[1] = 1;
  while (!q.empty()) {
    int node = q.front();
    q.pop();
    for (auto i : tree[node]) {
      if (k == edges) return;
      if (!vis[i]) {
        mp[{min(i, node), max(i, node)}]++;
        edges++;
        if (edges == k) return;
        vis[i] = 1;
        q.push(i);
      }
    }
  }
}
void get_tree() {
  priority_queue<
      pair<long long int, pair<long long int, long long int> >,
      vector<pair<long long int, pair<long long int, long long int> > >,
      greater<pair<long long int, pair<long long int, long long int> > > >
      pq;
  pq.push({0, {1, 0}});
  while (!pq.empty()) {
    auto cur = pq.top();
    pq.pop();
    if (vis[cur.second.first]) continue;
    vis[cur.second.first] = 1;
    dist[cur.second.first] = cur.first;
    parent[cur.second.first] = cur.second.second;
    for (auto i : v[cur.second.first]) {
      if (!vis[i.first] && dist[i.first] > i.second + cur.first)
        pq.push({i.second + cur.first, {i.first, cur.second.first}});
    }
  }
  memset(vis, 0, sizeof(vis));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, k, l, r, wt, i;
  cin >> n >> m >> k;
  vector<pair<int, int> > node(N);
  for (int i = 1; i <= m; ++i) {
    cin >> l >> r >> wt;
    v[l].push_back({r, wt});
    v[r].push_back({l, wt});
    if (l > r) swap(l, r);
    node[i].first = l;
    node[i].second = r;
  }
  for (int i = 1; i <= n; ++i) {
    dist[i] = 1e18;
    parent[i] = i;
  }
  get_tree();
  for (int i = 2; i <= n; ++i) {
    int x = parent[i];
    tree[x].push_back(i);
    tree[i].push_back(x);
  }
  bfs(min(k, n - 1));
  for (int i = 1; i <= m; ++i) {
    if (mp[node[i]]) ans.push_back(i);
  }
  cout << ans.size() << '\n';
  for (auto i : ans) cout << i << ' ';
  return 0;
}
