#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const long long LINF = (long long)INF * INF;
const int MAX = 2e5;
const double EPS = 1e-9;
const double PI = acos(-1.);
int n, m, k;
vector<pair<int, long long> > g[300005];
set<pair<pair<int, int>, int> > elist;
set<int> ans;
int siz[300005];
namespace D {
vector<long long> d;
vector<pair<long long, long long> > p;
void go() {
  d.resize(n, LINF);
  p.resize(n);
  d[0] = 0;
  priority_queue<pair<long long, long long> > q;
  q.push(make_pair(0LL, 0LL));
  while (!q.empty()) {
    long long v = q.top().second, cur_d = -q.top().first;
    q.pop();
    if (cur_d > d[v]) continue;
    for (size_t j = 0; j < g[v].size(); ++j) {
      long long to = g[v][j].first, len = g[v][j].second;
      if (d[v] + len < d[to]) {
        d[to] = d[v] + len;
        p[to] = make_pair(v, len);
        q.push(make_pair(-d[to], to));
      }
    }
  }
}
}  // namespace D
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = (0); i < (m); ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    x--;
    y--;
    g[x].push_back(make_pair(y, z));
    g[y].push_back(make_pair(x, z));
    if (x > y) swap(x, y);
    elist.insert(make_pair(make_pair(x, y), i + 1));
  }
  D::go();
  for (int i = (0); i < (n); ++i) {
    g[i].clear();
  }
  for (int i = (1); i < (n); ++i) {
    int u = D::p[i].first;
    int v = i;
    int w = D::p[i].second;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
    if (u > v) swap(u, v);
    int id = elist.lower_bound(make_pair(make_pair(u, v), -1))->second;
    ans.insert(id);
  }
  if (k == 0) {
    cout << 0;
    return 0;
  }
  set<int> foo;
  for (int i = (0); i < (n); ++i) {
    siz[i] = (int)g[i].size();
    if ((int)g[i].size() == 1) {
      foo.insert(i);
    }
  }
  int cur = n - 1;
  while (cur > k) {
    int u = *foo.begin();
    foo.erase(foo.begin());
    if (u == 0) continue;
    siz[u] = -1;
    for (int i = (0); i < ((int)g[u].size()); ++i) {
      int v = g[u][i].first;
      if (siz[v] == 2) {
        if (v) foo.insert(v);
      }
      if (siz[v] != -1) {
        siz[v]--;
        int x = u;
        int y = v;
        if (x > y) swap(x, y);
        int id = elist.lower_bound(make_pair(make_pair(x, y), -1))->second;
        ans.erase(id);
      }
    }
    cur--;
  }
  cout << ans.size() << endl;
  for (auto& iter : ans) {
    cout << iter << ' ';
  }
  return 0;
}
