#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long INF = 1011111111;
const long long LLINF = 1000111000111000111LL;
const long double EPS = 1e-10;
const long double PI = 3.14159265358979323;
using namespace std;
long long powm(long long base, long long exp, long long mod = MOD) {
  long long ans = 1;
  while (exp) {
    if (exp & 1) ans = (ans * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return ans;
}
const long long N = 1000005;
map<pair<long long, long long>, long long> mm;
vector<pair<long long, long long>> a[N];
long long dis[N], par[N];
bool vis[N] = {0};
class prioritize {
 public:
  bool operator()(pair<long long, long long>& p1,
                  pair<long long, long long>& p2) {
    return p1.second > p2.second;
  }
};
void dk(long long source) {
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 prioritize>
      pq;
  pq.push(make_pair(source, dis[source] = 0));
  while (!pq.empty()) {
    pair<long long, long long> curr = pq.top();
    pq.pop();
    if (vis[curr.first]) continue;
    vis[curr.first] = true;
    for (long long i = 0; i < a[curr.first].size(); i++)
      if (!vis[a[curr.first][i].first] and
          a[curr.first][i].second + curr.second < dis[a[curr.first][i].first]) {
        par[a[curr.first][i].first] = curr.first;
        pq.push(make_pair(a[curr.first][i].first,
                          (dis[a[curr.first][i].first] =
                               a[curr.first][i].second + curr.second)));
      }
  }
}
set<long long> final_edges;
set<pair<long long, long long>> rem;
vector<pair<pair<long long, long long>, long long>> edges;
long long deg[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k, x, y, w;
  cin >> n >> m >> k;
  for (long long i = 1; i < m + 1; i++) {
    cin >> x >> y >> w;
    edges.push_back(make_pair(make_pair(x, y), w));
    a[x].push_back(make_pair(y, w));
    a[y].push_back(make_pair(x, w));
    mm[make_pair(x, y)] = mm[make_pair(y, x)] = i;
  }
  if (k == 0) {
    cout << 0 << '\n';
    return 0;
  }
  for (long long i = 1; i < n + 1; i++) dis[i] = LLINF, vis[i] = 0;
  par[1] = 1;
  dk(1);
  for (long long i = 1; i < n + 1; i++) {
    if (i != 1) {
      deg[par[i]]++;
      deg[i]++;
      final_edges.insert(mm[make_pair(par[i], i)]);
    }
  }
  for (long long i = 2; i < n + 1; i++) rem.insert(make_pair(deg[i], i));
  if (k >= n - 1) {
    cout << (long long)((final_edges).size()) << '\n';
    for (auto i : final_edges) cout << i << " ";
    return 0;
  }
  while ((long long)((rem).size()) != 0 and
         (long long)((final_edges).size()) != k) {
    pair<long long, long long> tmp = *rem.begin();
    rem.erase(tmp);
    if (par[tmp.second] != 1) {
      rem.erase(make_pair(deg[par[tmp.second]], par[tmp.second]));
      deg[par[tmp.second]]--;
      rem.insert(make_pair(deg[par[tmp.second]], par[tmp.second]));
    }
    final_edges.erase(mm[make_pair(par[tmp.second], tmp.second)]);
  }
  cout << (long long)((final_edges).size()) << '\n';
  for (auto i : final_edges) cout << i << " ";
  return 0;
}
