Problem: The MST (Meaningless State Team) company won another tender for an important state reform in Berland.

There are n cities in Berland, some pairs of the cities are connected by roads. Each road has its price. One can move along any road in any direction. The MST team should carry out the repair works on some set of roads such that one can get from any city to any other one moving only along the repaired roads. Moreover, this set should contain exactly k capital roads (that is, the roads that start or finish in the capital). The number of the capital is 1.

As the budget has already been approved, the MST Company will profit by finding the set with minimum lengths of roads.

Input

The first input line contains three integers n, m, k (1 ≤ n ≤ 5000;0 ≤ m ≤ 105;0 ≤ k < 5000), where n is the number of cities in the country, m is the number of roads in the country, k is the number of capital roads in the required set. Then m lines enumerate the roads in question. Each road is specified by three numbers ai, bi, wi (1 ≤ ai, bi ≤ n; 1 ≤ w ≤ 105), where ai, bi are the numbers of cities linked by a road and wi is its length. 

Between each pair of cities no more than one road exists. There are no roads that start and finish in one city. The capital's number is 1.

Output

In the first line print the number of roads in the required set. The second line should contain the numbers of roads included in the sought set. If the sought set does not exist, print -1.

Examples

Input

4 5 2
1 2 1
2 3 1
3 4 1
1 3 3
1 4 2


Output

3
1 5 2 

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;
public class h {
public static void main(String[] args) throws IOException
{
    input.init(System.in);
    PrintWriter out = new PrintWriter(System.out);
    n = input.nextInt();
    m = input.nextInt();
    k = input.nextInt();
    int count = 0;
    Edge[] data = new Edge[m];
    for(int i = 0; i<m; i++)
    {
        int a = input.nextInt()-1, b = input.nextInt()-1, c = input.nextInt();
        if(a == 0 || b == 0) count++;
        data[i] = new Edge(a, b, c, i);
    }
    if(count < k) out.println(-1);
    else
    {
        boolean found = false;
        double lo = -100001, hi = 100001;
        while(lo < hi - 1e-9)
        {
            double mid = (lo+hi)/2;
            Edge[] cur = new Edge[m];
            for(int i = 0; i<m; i++) cur[i] = new Edge(data[i].a, data[i].b, data[i].c + ((data[i].a == 0 || data[i].b == 0) ? mid : 0), data[i].i);
            int deg = deg(cur);
            if(deg < k) hi = mid;
            else if(deg > k) lo = mid;
            else
            {
                found = true;
                break;
            }
        }
        if(found)
        {
            out.println(es.size());
            for(int x : es) out.print(x+" ");
        }
        else out.println(-1);
    }
    out.close();
}
static int n, m, k;
static int deg(Edge[] el)
{
    es = new ArrayList<Integer>();
    Arrays.sort(el);
    int res = 0;
    DisjointSet ds = new DisjointSet(n);
    //System.out.println("go");
    for(Edge e : el)
    {
        //System.out.println(e.a+" "+e.b);
        if(ds.find(e.a) == ds.find(e.b)) continue;
        ds.union(e.a, e.b);
        if(e.a == 0 || e.b == 0)
        {
            res++;
        }
        es.add(e.i+1);
    }
    return res;
}
static ArrayList<Integer> es;
static class Edge implements Comparable<Edge>
{
    int a, b, i;
    double c;
    public Edge(int aa, int bb, double cc, int ii)
    {
        a = aa; b = bb; c = cc; i = ii;
        c += i * 1e-6;
    }
    @Override
    public int compareTo(Edge o) {
        // TODO Auto-generated method stub
        return (int)Math.signum(c - o.c);
    }
}
public static class DisjointSet
{
    int[] map; //negative if root, more negative means bigger set; if nonnegative, then it indicates the parent 
    public DisjointSet(int n)
    {
        map = new int[n+1];
        Arrays.fill(map, -1);
    }
    public int find(int x)
    {
        if(map[x] < 0)
            return x;
        else
        {
            map[x] = find(map[x]);
            return map[x];
        }
    }
    public void union(int a, int b)
    {
        int roota = find(a), rootb = find(b);
        if(roota == rootb)
            return;
        if(map[roota] < map[rootb])
        {
            map[roota] += map[rootb]; //add the sizes
            map[rootb] = roota; //connect the smaller to the bigger
        }
        else
        {
            map[rootb] += map[roota];
            map[roota] = rootb;
        }
    }
}
public static class input {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }
    
    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }
}
}