#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m, k;
long long dp[N];
bool us[N];
vector<pair<pair<int, int>, int> > g[N];
set<pair<long long, int> > q;
queue<int> b;
vector<int> ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    g[x].push_back(make_pair(make_pair(y, z), i));
    g[y].push_back(make_pair(make_pair(x, z), i));
  }
  for (int i = 1; i <= n; ++i) {
    dp[i] = 1e18;
  }
  dp[1] = 0;
  q.insert(make_pair(0, 1));
  while (!q.empty()) {
    int x = q.begin()->second;
    q.erase(q.begin());
    for (int i = 0; i < g[x].size(); ++i) {
      int y = g[x][i].first.first, z = g[x][i].first.second;
      if (dp[x] + z < dp[y]) {
        q.erase(make_pair(dp[y], y));
        dp[y] = dp[x] + z;
        q.insert(make_pair(dp[y], y));
      }
    }
  }
  b.push(1);
  while (!b.empty()) {
    if (ans.size() == k) break;
    int x = b.front();
    b.pop();
    for (int i = 0; i < g[x].size(); ++i) {
      int y = g[x][i].first.first, z = g[x][i].first.second;
      if (dp[x] + z == dp[y] && !us[y]) {
        b.push(y);
        us[y] = 1;
        ans.push_back(g[x][i].second);
      }
      if (ans.size() == k) break;
    }
  }
  cout << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); ++i) {
    cout << ans[i] << " ";
  }
}
