#include <cstdio>
#include <cstring>
#include <utility>
#include <algorithm>
using namespace std;
const int N = 3e5 + 10, M = N << 1;
int adj[N], ecnt = 1, dis[N];
struct
{
    int from, to, len, next, val;
} E[M];
inline void addEdge(int f, int t, int l)
{
    ecnt++;
    E[ecnt].next = adj[f];
    E[ecnt].from = f;
    E[ecnt].len = l;
    E[ecnt].to = t;
    adj[f] = ecnt;
}
void spfa(int S)
{
    static int q[N << 2];
    static bool inq[N];
    memset(inq, 0, sizeof(inq));
    int h = 0, t = 0;
    for (inq[q[t++] = S] = true; h ^ t; inq[h++] = false)
        for (int e = adj[q[h]]; e; e = E[e].next)
            if (dis[E[e].to] > dis[q[h]] + E[e].len)
            {
                dis[E[e].to] = dis[q[h]] + E[e].len;
                if (!inq[E[e].to]) inq[q[t++] = E[e].to] = true;
            }
}
pair<int, int> P[N];
bool flg[N];
int main()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0, x, y, w; i < m; i++)
    {
        scanf("%d%d%d", &x, &y, &w);
        addEdge(x, y, w);
        addEdge(y, x, w);
    }
    spfa(1);
    for (int i = 1; i <= ecnt; i++)
        if (dis[E[i].from] == dis[E[i].to] + E[i].len)
            E[i].val++;
    for (int i = 2; i <= ecnt; i += 2)
        P[i >> 1].first = max(E[i].val, E[i + 1].val), P[i >> 1].second = (i >> 1);
    sort(P + 1, P + (ecnt >> 1) + 1);
    printf("%d\n", k);
    for (int i = 1; i <= m - k; i++)
        flg[P[i].second] = true;
    for (int i = 1; i <= m; i++)
        if (!flg[i])
            printf("%d ", i);
    return 0;
}