#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e18;
struct dta {
  int u, id;
  dta(int _u = 0, int _id = 0) {
    u = _u;
    id = _id;
  }
};
struct TDij {
  long long val;
  int x;
  TDij(long long _val = 0, int _x = 0) {
    x = _x;
    val = _val;
  }
};
inline bool operator<(const TDij &a, const TDij &b) { return (a.val > b.val); }
int n, m, k, cost[300010], trace[300010], delneed;
bool flag[300010];
long long F[300010];
vector<dta> A[300010];
priority_queue<TDij> Q;
void dijks() {
  memset(flag, true, sizeof(flag));
  memset(trace, 0, sizeof(trace));
  for (int i = 2; i <= n; ++i) F[i] = oo;
  F[1] = 0;
  Q.push(TDij(0, 1));
  while (!Q.empty()) {
    TDij topx = Q.top();
    Q.pop();
    if (topx.val != F[topx.x]) continue;
    int u = topx.x;
    for (int i = 0; i <= A[u].size() - 1; ++i) {
      if (F[A[u][i].u] > F[u] + cost[A[u][i].id]) {
        F[A[u][i].u] = F[u] + cost[A[u][i].id];
        flag[trace[A[u][i].u]] = true;
        trace[A[u][i].u] = A[u][i].id;
        flag[A[u][i].id] = false;
        Q.push(TDij(F[A[u][i].u], A[u][i].u));
      }
    }
  }
}
void dfs(int x, int par, int pared) {
  for (int i = 0; i <= A[x].size() - 1; ++i)
    if (A[x][i].u != par && !flag[A[x][i].id]) {
      dfs(A[x][i].u, x, A[x][i].id);
      if (delneed == 0) return;
    }
  if (delneed > 0) {
    (--delneed);
    flag[pared] = true;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) {
    int u, v;
    cin >> u >> v >> cost[i];
    A[u].push_back(dta(v, i));
    A[v].push_back(dta(u, i));
  }
  dijks();
  delneed = m - k;
  if (!delneed) {
    for (int i = 1; i <= m; ++i) delneed += (!flag[i]);
    cout << delneed << "\n";
    for (int i = 1; i <= m; ++i)
      if (!flag[i]) cout << i << ' ';
    return 0;
  }
  for (int i = 1; i <= m; ++i)
    if (flag[i]) {
      if ((--delneed) == 0) {
        cout << k << "\n";
        for (int j = 1; j <= i; ++j)
          if (!flag[j]) cout << j << ' ';
        for (int j = i + 1; j <= m; ++j) cout << j << ' ';
        return 0;
      }
    }
  dfs(1, 0, 0);
  cout << k << "\n";
  for (int i = 1; i <= m; ++i)
    if (!flag[i]) cout << i << ' ';
  return 0;
}
