#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 3e5 + 5;
struct qnode {
  int v;
  long long c;
  int cnt;
  qnode(int _v = 0, long long _c = 0, int _cnt = 0) : v(_v), c(_c), cnt(_cnt) {}
  bool operator<(const qnode& r) const {
    if (c == r.c) return cnt > r.cnt;
    return c > r.c;
  }
};
struct Edge {
  int v;
  int id;
  long long cost;
  Edge(int _v = 0, int _id = 0, long long _cost = 0)
      : v(_v), id(_id), cost(_cost) {}
};
vector<Edge> E[maxn];
bool vis[maxn];
long long dist[maxn];
int cnt[maxn];
int fa[maxn], faedge[maxn];
void Dijkstra(int N) {
  memset(vis, false, sizeof(vis));
  for (int i = 1; i <= N; i++) dist[i] = INF, cnt[i] = maxn;
  priority_queue<qnode> Q;
  dist[1] = 0;
  cnt[1] = 0;
  fa[1] = 1;
  Q.push(qnode(1, 0));
  qnode tmp;
  while (!Q.empty()) {
    tmp = Q.top();
    Q.pop();
    int u = tmp.v;
    if (vis[u]) continue;
    vis[u] = true;
    for (int i = 0; i < (int)E[u].size(); i++) {
      int v = E[u][i].v;
      long long cost = E[u][i].cost;
      int id = E[u][i].id;
      if (!vis[v]) {
        if (dist[v] > dist[u] + cost) {
          dist[v] = dist[u] + cost;
          cnt[v] = cnt[u] + 1;
          fa[v] = u;
          faedge[v] = id;
          Q.push(qnode(v, dist[v], cnt[v]));
        } else if (dist[v] == dist[u] + cost && cnt[v] > cnt[u] + 1) {
          cnt[v] = cnt[u] + 1;
          fa[v] = u;
          faedge[v] = id;
          Q.push(qnode(v, dist[v], cnt[v]));
        }
      }
    }
  }
}
void addedge(int u, int v, long long w, int i) {
  E[u].push_back(Edge(v, i, w));
  E[v].push_back(Edge(u, i, w));
}
int N, M, K;
vector<int> son[maxn];
queue<int> BQ;
vector<int> ans;
void bfs() {
  BQ.push(1);
  while (!BQ.empty() && K > 0) {
    int u = BQ.front();
    BQ.pop();
    int len = son[u].size();
    for (int i = 0; i < len; i++) {
      int v = son[u][i];
      if (K > 0) {
        K--;
        ans.push_back(faedge[v]);
        BQ.push(v);
      } else
        break;
    }
  }
}
int main() {
  cin >> N >> M >> K;
  for (int i = 1; i <= M; i++) {
    int u, v;
    long long w;
    scanf("%d%d%lld", &u, &v, &w);
    addedge(u, v, w, i);
  }
  Dijkstra(N);
  for (int i = 2; i <= N; i++) {
    son[fa[i]].push_back(i);
  }
  bfs();
  int len = ans.size();
  cout << len << endl;
  bool firstprint = true;
  for (int i = 0; i < len; i++) {
    if (firstprint)
      firstprint = false;
    else
      printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
  return 0;
}
