#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
template <typename first, typename second>
ostream& operator<<(ostream& os, const pair<first, second>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ",";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream& operator<<(ostream& os, const map<first, second>& v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
void faltu() { cerr << '\n'; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << '\n';
}
template <typename T, typename... hello>
void faltu(T arg, const hello&... rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
const int mx = 3e5 + 5;
int n, m, k;
vector<pair<pair<int, int>, int>> adjlist[mx];
vector<pair<int, int>> adjlist2[mx];
vector<int> store;
long long dist[mx];
pair<int, int> parent[mx];
void djikstra(int source) {
  for (int i = 0; i < mx; ++i) dist[i] = infLL;
  dist[source] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  pq.push(make_pair(0, source));
  while (!pq.empty()) {
    pair<long long, long long> Front = pq.top();
    pq.pop();
    long long d = Front.first, u = Front.second;
    if (d > dist[u]) continue;
    for (int j = 0; j < adjlist[u].size(); j++) {
      auto v = adjlist[u][j];
      if (dist[u] + v.first.second < dist[v.first.first]) {
        dist[v.first.first] = dist[u] + v.first.second;
        pq.push(make_pair(dist[v.first.first], v.first.first));
        parent[v.first.first] = make_pair(u, v.second);
      }
    }
  }
}
bool b[mx];
int cnt = 0;
bool e[mx];
void dfs(int u, int par, int edge) {
  for (auto v : adjlist2[u]) {
    if (v.first != par) dfs(v.first, u, v.second);
  }
  if (cnt) {
    e[edge] = 1;
    --cnt;
  }
}
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 x, y, w;
    cin >> x >> y >> w;
    adjlist[x].push_back(make_pair(make_pair(y, w), i));
    adjlist[y].push_back(make_pair(make_pair(x, w), i));
  }
  djikstra(1);
  for (int i = 1; i <= n; ++i) {
    if (parent[i].first) {
      adjlist2[i].push_back(parent[i]);
      adjlist2[parent[i].first].push_back(make_pair(i, parent[i].second));
    }
  }
  cnt = m - k;
  for (int i = 1; i <= n; ++i) {
    for (auto x : adjlist2[i]) {
      b[x.second] = 1;
    }
  }
  for (int i = 1; i <= m; ++i) {
    if (!b[i] && cnt) {
      --cnt;
      e[i] = 1;
    }
  }
  dfs(1, 0, 0);
  for (int i = 1; i <= m; ++i)
    if (!e[i]) store.push_back(i);
  cout << (int)store.size() << '\n';
  for (auto x : store) cout << x << " ";
  cout << '\n';
}
