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:
//package vkcup2012.r1;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;

public class B {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		int n = ni(), k = ni();
		int[][] stool = new int[n][];
		int[][] pencil = new int[n][];
		int p = 0, q = 0;
		long sum = 0;
		int min = Integer.MAX_VALUE;
		for(int i = 0;i < n;i++){
			int v = ni();
			int kind = ni();
			if(kind == 1){
				stool[p++] = new int[]{v, i+1};
			}else{
				pencil[q++] = new int[]{v, i+1};
			}
			sum += v;
			min = Math.min(min, v);
		}
		stool = Arrays.copyOf(stool, p);
		pencil = Arrays.copyOf(pencil, q);
		Arrays.sort(stool, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				if(a[0] - b[0] != 0)return a[0] - b[0];
				return a[1] - b[1];
			}
		});
		Arrays.sort(pencil, new Comparator<int[]>() {
			public int compare(int[] a, int[] b) {
				if(a[0] - b[0] != 0)return a[0] - b[0];
				return a[1] - b[1];
			}
		});
		
		if(k == 1){
			if(p == 0)min = 0;
			out.printf("%.1f\n", sum - (double)min/2);
			out.print(n);
			for(int i = 0;i < n;i++){
				out.print(" ");
				out.print(i+1);
			}
			out.println();
			return;
		}
		
		if(p >= k){
			long all = 0;
			for(int i = 0;i < k-1;i++){
				all += stool[p-1-i][0];
			}
			if(q > 0){
				all += Math.min(stool[0][0], pencil[0][0]);
			}else{
				all += stool[0][0];
			}
			
			long other = 0;
			for(int i = 0;i < k-2;i++){
				other += stool[p-1-i][0];
			}
			other += stool[0][0];
			
			if(all >= other){
				out.printf("%.1f\n", sum-(double)all/2);
				for(int i = 0;i < k-1;i++){
					out.println("1 " + stool[p-1-i][1]);
				}
				out.print(n-(k-1));
				for(int i = 0;i <= p-1-(k-1);i++){
					out.print(" ");
					out.print(stool[i][1]);
				}
				for(int[] h : pencil){
					out.print(" ");
					out.print(h[1]);
				}
				out.println();
			}else{
				out.printf("%.1f\n", sum-(double)other/2);
				for(int i = 0;i < k-2;i++){
					out.println("1 " + stool[p-1-i][1]);
				}
				out.print(p-1-(k-2)+1);
				for(int i = 0;i <= p-1-(k-2);i++){
					out.print(" ");
					out.print(stool[i][1]);
				}
				out.println();
				out.print(pencil.length);
				for(int[] h : pencil){
					out.print(" ");
					out.print(h[1]);
				}
				out.println();
			}
		}else{
			long all = 0;
			for(int i = 0;i < p;i++)all += stool[i][0];
			out.printf("%.1f\n", sum-(double)all/2);
			for(int i = 0;i < p;i++){
				out.println("1 " + stool[i][1]);
			}
			for(int i = 0;i < k-p-1;i++){
				out.println("1 " + pencil[i][1]);
			}
			out.print((q-1)-(k-p-1)+1);
			for(int i = k-p-1;i < q;i++){
				out.print(" ");
				out.print(pencil[i][1]);
			}
			out.println();
		}
	}
	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception
	{
		new B().run();
	}
	
	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}
			
			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}
	
	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}
	
	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}
	
	
	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}