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.*;
import java.util.*;

import static java.lang.Math.*;

public class VKCup_Round1_B implements Runnable {

	final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
	
	BufferedReader in;
	PrintWriter out;
	StringTokenizer tok;

	public static void main(String[] args) {
		new Thread(null, new VKCup_Round1_B(), "", 256 * (1L << 20)).start();
	}

	@Override
	public void run() {
		try {
			long startTime = System.currentTimeMillis();
			if (ONLINE_JUDGE) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			} else {
				in = new BufferedReader(new FileReader("input.txt"));
				out = new PrintWriter("output.txt");
			}
			Locale.setDefault(Locale.US);
			tok = new StringTokenizer("");
			solve();
			in.close();
			out.close();
			long freeMemory = Runtime.getRuntime().freeMemory();
			long totalMemory = Runtime.getRuntime().totalMemory();
			long endTime = System.currentTimeMillis();
			System.err.println("Time = " + (endTime - startTime));
			System.err.println("Memory = " + ((totalMemory - freeMemory) >> 10));
		} catch (Throwable t) {
			t.printStackTrace(System.err);
			System.exit(-1);
		}
	}

	String readString() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	int readInt() throws IOException {
		return Integer.parseInt(readString());
	}

	long readLong() throws IOException {
		return Long.parseLong(readString());
	}

	double readDouble() throws IOException {
		return Double.parseDouble(readString());
	}
	
	void debug(Object... o) {
		if (!ONLINE_JUDGE) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	/** http://pastebin.com/j0xdUjDn */
	static class Utils {

		private Utils() {}

		public static void mergeSort(int[] a) {
			mergeSort(a, 0, a.length - 1);
		}

		private static final int MAGIC_VALUE = 50;

		private static void mergeSort(int[] a, int leftIndex, int rightIndex) {
			if (leftIndex < rightIndex) {
				if (rightIndex - leftIndex <= MAGIC_VALUE) {
					insertionSort(a, leftIndex, rightIndex);
				} else {
					int middleIndex = (leftIndex + rightIndex) / 2;
					mergeSort(a, leftIndex, middleIndex);
					mergeSort(a, middleIndex + 1, rightIndex);
					merge(a, leftIndex, middleIndex, rightIndex);
				}
			}
		}

		private static void merge(int[] a, int leftIndex, int middleIndex, int rightIndex) {
			int length1 = middleIndex - leftIndex + 1;
			int length2 = rightIndex - middleIndex;
			int[] leftArray = new int[length1];
			int[] rightArray = new int[length2];
			System.arraycopy(a, leftIndex, leftArray, 0, length1);
			System.arraycopy(a, middleIndex + 1, rightArray, 0, length2);
			for (int k = leftIndex, i = 0, j = 0; k <= rightIndex; k++) {
				if (i == length1) {
					a[k] = rightArray[j++];
				} else if (j == length2) {
					a[k] = leftArray[i++];
				} else {
					a[k] = leftArray[i] <= rightArray[j] ? leftArray[i++] : rightArray[j++];
				}
			}
		}

		private static void insertionSort(int[] a, int leftIndex, int rightIndex) {
			for (int i = leftIndex + 1; i <= rightIndex; i++) {
				int current = a[i];
				int j = i - 1;
				while (j >= leftIndex && a[j] > current) {
					a[j + 1] = a[j];
					j--;
				}
				a[j + 1] = current;
			}
		}

	}

	// solution
	
	class Pen implements Comparable<Pen> {
		int i;
		long c;
		public Pen(int i, long c) {
			this.i = i;
			this.c = c;
		}
		@Override
		public int compareTo(Pen o) {
			if (c < o.c) return -1;
			if (c > o.c) return 1;
			return 0;
		}
		@Override
		public String toString() {
			return "Pen [c=" + c + ", i=" + i + "]";
		}
	}
	
	class Stool implements Comparable<Stool> {
		int i;
		long c;
		public Stool(int i, long c) {
			this.i = i;
			this.c = c;
		}
		@Override
		public int compareTo(Stool o) {
			if (c < o.c) return -1;
			if (c > o.c) return 1;
			return 0;
		}
		@Override
		public String toString() {
			return "Stool [c=" + c + ", i=" + i + "]";
		}
	}
	
	void solve() throws IOException {
		int n = readInt();
		int k = readInt();
		ArrayList<Pen> a = new ArrayList<Pen>();
		ArrayList<Stool> b = new ArrayList<Stool>();
		for (int i = 0; i < n; i++) {
			long c = readLong();
			c *= 2;
			int type = readInt();
			if (type == 1) {
				b.add(new Stool(i, c));
			} else {
				a.add(new Pen(i, c));
			}
		}
		Collections.sort(a);
		Collections.sort(b);
		ArrayList<Integer>[] ans = new ArrayList[k];
		for (int i = 0; i < k; i++) {
			ans[i] = new ArrayList<Integer>();
		}
		int aRight = a.size() - 1, bRight = b.size() - 1;
		int aLeft = 0, bLeft = 0;
		int remK = k;
		int remN = n;
		long totalCost = 0;
		for (int i = 0; i < k; i++) {
			if (i == k-1) {
				for (int j = aLeft; j <= aRight; j++) {
					ans[i].add(a.get(j).i);
					totalCost += a.get(j).c;
				}
				for (int j = bLeft; j <= bRight; j++) {
					ans[i].add(b.get(j).i);
					totalCost += b.get(j).c;
				}
				if (bLeft <= bRight) {
					if (aLeft > aRight) {
						totalCost -= b.get(bLeft).c / 2;
					} else {
						totalCost -= min(a.get(aLeft).c, b.get(bLeft).c) / 2;
					}
				}
				continue;
			}
			if (remN == remK) {
				if (bLeft <= bRight) {
					ans[i].add(b.get(bRight).i);
					totalCost += b.get(bRight).c / 2;
					bRight--;
				} else {
					ans[i].add(a.get(aRight).i);
					totalCost += a.get(aRight).c;
					aRight--;
				}
				remN--;
				remK--;
				continue;
			}
			if (bLeft > bRight) {
				ans[i].add(a.get(aRight).i);
				totalCost += a.get(aRight).c;
				aRight--;
				remN--;
				remK--;
				continue;
			}
			if (aLeft > aRight) {
				ans[i].add(b.get(bRight).i);
				totalCost += b.get(bRight).c / 2;
				bRight--;
				remN--;
				remK--;
				continue;
			}
			ans[i].add(b.get(bRight).i);
			totalCost += b.get(bRight).c / 2;
			bRight--;
			remN--;
			remK--;
			continue;
		}
		out.print(totalCost / 2);
		if (totalCost % 2 == 0) {
			out.println(".0");
		} else {
			out.println(".5");
		}
		for (int i = 0; i < k; i++) {
			out.print(ans[i].size());
			for (int x : ans[i]) {
				out.print(" ");
				out.print(x+1);
			}
			out.println();
		}
	}

}