Problem: One day Polycarpus stopped by a supermarket on his way home. It turns out that the supermarket is having a special offer for stools. The offer is as follows: if a customer's shopping cart contains at least one stool, the customer gets a 50% discount on the cheapest item in the cart (that is, it becomes two times cheaper). If there are several items with the same minimum price, the discount is available for only one of them!

Polycarpus has k carts, and he wants to buy up all stools and pencils from the supermarket. Help him distribute the stools and the pencils among the shopping carts, so that the items' total price (including the discounts) is the least possible.

Polycarpus must use all k carts to purchase the items, no shopping cart can remain empty. Each shopping cart can contain an arbitrary number of stools and/or pencils.

Input

The first input line contains two integers n and k (1 ≤ k ≤ n ≤ 103) — the number of items in the supermarket and the number of carts, correspondingly. Next n lines describe the items as "ci ti" (without the quotes), where ci (1 ≤ ci ≤ 109) is an integer denoting the price of the i-th item, ti (1 ≤ ti ≤ 2) is an integer representing the type of item i (1 for a stool and 2 for a pencil). The numbers in the lines are separated by single spaces.

Output

In the first line print a single real number with exactly one  decimal place — the minimum total price of the items, including the discounts.

In the following k lines print the descriptions of the items in the carts. In the i-th line print the description of the i-th cart as "t b1 b2 ... bt" (without the quotes), where t is the number of items in the i-th cart, and the sequence b1, b2, ..., bt (1 ≤ bj ≤ n) gives the indices of items to put in this cart in the optimal distribution. All indices of items in all carts should be pairwise different, each item must belong to exactly one cart. You can print the items in carts and the carts themselves in any order. The items are numbered from 1 to n in the order in which they are specified in the input.

If there are multiple optimal distributions, you are allowed to print any of them.

Examples

Input

3 2
2 1
3 2
3 1


Output

5.5
2 1 2
1 3


Input

4 3
4 1
1 2
2 2
3 2


Output

8.0
1 1
2 4 2
1 3

Note

In the first sample case the first cart should contain the 1st and 2nd items, and the second cart should contain the 3rd item. This way each cart has a stool and each cart has a 50% discount for the cheapest item. The total price of all items will be: 2·0.5 + (3 + 3·0.5) = 1 + 4.5 = 5.5.

Solution (in JAVA):

Solution:

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pttrung
 */
public class B {

    public static void main(String[] args) throws FileNotFoundException {

        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        //     PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        int n = in.nextInt();
        int k = in.nextInt();
        ArrayList<Node>[] cart = new ArrayList[k];
        ArrayList<Node> stool = new ArrayList();
        ArrayList<Node> pencil = new ArrayList();
        for (int i = 0; i < n; i++) {
            int price = in.nextInt();
            int type = in.nextInt();
            if (type == 1) {
                stool.add(new Node(i + 1, type, price));
            } else {
                pencil.add(new Node(i + 1, type, price));
            }
        }
        Collections.sort(stool);
        Collections.sort(pencil);
        long[] min = new long[k];
        boolean[] check = new boolean[k];
        for (int i = 0; i < k; i++) {
            cart[i] = new ArrayList();
            min[i] = Integer.MAX_VALUE;
        }
        int index = Math.max(stool.size() - k , 0);
        int end = index;
        
        while (index < stool.size()) {
            boolean found = false;
            for (int i = 0; i < k; i++) {
                if(!check[i]){        
                    found = true;
                    check[i] = true;
                    cart[i].add(stool.get(index));
                    min[i] = Math.min(min[i], stool.get(index).price);
                    index++;
                    break;                    
                }
            }            
        }
        for(int i = 0 ; i < end ; i++){
            cart[0].add(stool.get(i));
            min[0] = Math.min(min[0], stool.get(i).price);
        }
        index = 0;
        int max = 0;
        while(index < pencil.size()){
            boolean found = false;
            for(int i = 0; i < k; i++){
                if(!check[i] && cart[i].isEmpty()){
                   // System.out.println(i);
                    max = i;
                    cart[i].add(pencil.get(index));
                    min[i] = Math.min(min[i], pencil.get(index++).price );
                    found = true;
                    break;
                }
            }
            if(!found){
                while(index < pencil.size()){
                    cart[max].add(pencil.get(index));
                      min[max] = Math.min(min[max], pencil.get(index++).price );
                }
            }
        }



        double total = 0;
        for (int i = 0; i < k; i++) {
            boolean add = check[i];
            // System.out.println(" Start " + i + " " + cart[i].get(0).type);
            for (Node node : cart[i]) {
                if (node.price == min[i] && add) {
                    add = false;
                    total += (double) node.price * 0.5;
                } else {
                    total += node.price;
                }
            }
        }
        out.printf("%.1f\n",total);
        for (int i = 0; i < k; i++) {
            out.print(cart[i].size() + " ");
            for (Node node : cart[i]) {
                out.print(node.index + " ");
            }
            out.println();
        }
        out.close();
    }

    static class Node implements Comparable<Node> {

        int index, type; long price;

        public Node(int index, int type, long price) {
            this.index = index;
            this.type = type;
            this.price = price;
        }

        @Override
        public int compareTo(Node o) {
            if(price > o.price){
                return 1;
            }else if(price == o.price){
                return 0;
            }
            return -1;
        }
    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    public static double dist(Point a, Point b) {
        double val = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(val);
    }

    public static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static long pow(long a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long lcm(long a, long b) {
        return a * b / gcd(a, b);
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("input.txt")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}