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:
/* Codeforces Template */

import java.io.*;
import java.util.*;

import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					
					long prevTime = System.currentTimeMillis();
					new Main().run();
					System.err.println("Total time: " + (System.currentTimeMillis() - prevTime) + " ms");
					System.err.println("Memory status: " + memoryStatus());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start(); 
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
		in.close();
	}
	
	/*************************************************************** 
	 * Solution
	 **************************************************************/
	
	void solve() throws IOException  {
		int n = nextInt();
		int k = nextInt();
		
		Item[] items = new Item [n];
		long ans = 0L;
		for (int i = 0; i < n; i++) {
			items[i] = new Item(i + 1, nextLong(), nextInt());
			ans += items[i].cost << 1;
		}
		
		sort(items);
		
		long[][][] dp = new long [2][n + 1][k];
		long[][][] add = new long [2][n + 1][k];
		int[][][][] prev = new int [2][n + 1][k][];
		for (long[][] a : dp) for (long[] b : a) fill(b, -1L);
				
		dp[0][0][0] = 0L;
				
		for (int g = 0; g < n; g++) {
			Item item = items[g];
			for (int b = 0; b < k; b++) {
				for (int d = 0; d < 2; d++) {
					long cVal = dp[d][g][b];
					long cAdd = add[d][g][b];
					if (cVal == -1L) continue;
					
					{ // cur
						int nd = item.type == 1 ? 1 : d;
						long nAdd = nd == 0 ? 0 : item.cost;
						long nVal = cVal - cAdd + nAdd;
						if (dp[nd][g + 1][b] < nVal) {
							dp[nd][g + 1][b] = nVal;
							add[nd][g + 1][b] = nAdd;
							prev[nd][g + 1][b] = new int [] { d, b };
						}
					}
					
					if (b + 1 < k) { // nxt
						int nd = item.type == 1 ? 1 : 0;
						long nAdd = nd == 0 ? 0 : item.cost;
						long nVal = cVal + nAdd;
						if (dp[nd][g + 1][b + 1] < nVal) {
							dp[nd][g + 1][b + 1] = nVal;
							add[nd][g + 1][b + 1] = nAdd;
							prev[nd][g + 1][b + 1] = new int [] { d, b };
						}
					}
				}
			}
		}
	
		long best = max(dp[0][n][k - 1], dp[1][n][k - 1]);
		
//		out.println(0.5 * (ans - best));
		out.printf(Locale.US, "%.1f%n", 0.5 * (ans - best));
		
		List<Integer>[] bags = new ArrayList [k];
		for (int i = 0; i < k; i++) {
			bags[i] = new ArrayList<Integer>();
		}
		
		for (int d = (best == dp[0][n][k - 1] ? 0 : 1), g = n, b = k - 1; g > 0; ) {
			
//			System.out.println(d + " " + g + " " + b);
			
			int pd = prev[d][g][b][0];
			int pb = prev[d][g][b][1];

			bags[b].add(items[g - 1].id);
			
			d = pd;
			g--;
			b = pb;
		}
		
		for (int i = 0; i < k; i++) {
			out.print(bags[i].size());
			for (int x : bags[i]) {
				out.print(" " + x);
			}
			out.println();
		}
	}

	class Item implements Comparable<Item> {
		int id;
		long cost;
		int type;

		Item(int id, long cost, int type) {
			this.id = id;
			this.cost = cost;
			this.type = type;
		}

		@Override
		public int compareTo(Item item) {
			if (cost != item.cost) return cost < item.cost ? 1 : -1;
			return 0;
		}
		
		
	}
	
	/*************************************************************** 
	 * Input 
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	int[] nextIntArray(int size) throws IOException {
		int[] ret = new int [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextInt();
		return ret;
	}
	
	long[] nextLongArray(int size) throws IOException {
		long[] ret = new long [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextLong();
		return ret;
	}
	
	double[] nextDoubleArray(int size) throws IOException {
		double[] ret = new double [size];
		for (int i = 0; i < size; i++)
			ret[i] = nextDouble();
		return ret;
	}
	
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
	
	/*************************************************************** 
	 * Output 
	 **************************************************************/
	void printRepeat(String s, int count) {
		for (int i = 0; i < count; i++)
			out.print(s);
	}
	
	void printArray(int[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(long[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(double[] array) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.print(array[i]);
		}
		out.println();
	}
	
	void printArray(double[] array, String spec) {
		if (array == null || array.length == 0)
			return;
		for (int i = 0; i < array.length; i++) {
			if (i > 0) out.print(' ');
			out.printf(Locale.US, spec, array[i]);
		}
		out.println();
	}
	
	void printArray(Object[] array) {
		if (array == null || array.length == 0)
			return;
		boolean blank = false;
		for (Object x : array) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}
	
	@SuppressWarnings("rawtypes")
	void printCollection(Collection collection) {
		if (collection == null || collection.isEmpty())
			return;
		boolean blank = false;
		for (Object x : collection) {
			if (blank) out.print(' '); else blank = true;
			out.print(x);
		}
		out.println();
	}
	
	/*************************************************************** 
	 * Utility
	 **************************************************************/
	static String memoryStatus() {
		return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory() >> 20) + "/" + (Runtime.getRuntime().totalMemory() >> 20) + " MB";
	}
	
	static void checkMemory() {
		System.err.println(memoryStatus());
	}
	
	static long prevTimeStamp = Long.MIN_VALUE;
	
	static void updateTimer() {
		prevTimeStamp = System.currentTimeMillis();
	}
	
	static long elapsedTime() {
		return (System.currentTimeMillis() - prevTimeStamp);
	}
	
	static void checkTimer() {
		System.err.println(elapsedTime() + " ms");
	}
}