#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
int fx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int fy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int kx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky[] = {2, -2, 1, -1, 2, -2, 1, -1};
int TLx[] = {0, -1, -1, 0};
int TLy[] = {-1, -1, 0, 0};
int TRx[] = {-1, -1, 0, 0};
int TRy[] = {0, 1, 1, 0};
int BLx[] = {0, 1, 1, 0};
int BLy[] = {-1, -1, 0, 0};
int BRx[] = {0, 1, 1, 0};
int BRy[] = {1, 1, 0, 0};
struct node {
  int u;
  long long w;
  int par;
};
vector<node> G[300005];
bool vis[300005];
int dist[300005];
map<pair<int, int>, int> M;
vector<int> res;
class cmp {
 public:
  bool operator()(node &A, node &B) {
    if (A.w > B.w) return true;
    return false;
  }
};
void sp(int s, int k) {
  priority_queue<node, vector<node>, cmp> PQ;
  PQ.push({s, 0, s});
  while (!PQ.empty()) {
    int n = PQ.top().u;
    long long w = PQ.top().w;
    int par = PQ.top().par;
    PQ.pop();
    if (vis[n]) continue;
    vis[n] = 1;
    if (n != s) {
      int node = n;
      if (node > par) swap(node, par);
      res.push_back(M[make_pair(node, par)]);
      k--;
    }
    if (k <= 0) return;
    for (int i = 0; i < G[n].size(); i++) {
      int v = G[n][i].u;
      long long ww = G[n][i].w;
      PQ.push({v, w + ww, n});
    }
  }
}
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int u, v;
    long long w;
    scanf("%d%d%I64d", &u, &v, &w);
    if (u > v) swap(u, v);
    M[make_pair(u, v)] = i;
    G[u].push_back({v, w, u});
    G[v].push_back({u, w, v});
  }
  sp(1, k);
  cout << res.size() << "\n";
  for (int i = 0; i < res.size(); i++) cout << res[i] << ' ';
  return 0;
}
