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.
11 11
6 2
6 2
1 2
2 2
3 1
6 2
1 1
1 1
3 1
3 1
6 2
 21 7
14 1
882797755 2
17 1
906492329 2
209923513 2
802927469 2
949195463 2
677323647 2
2129083 2
2 1
13 1
539523264 2
7 1
8 1
12 1
363470241 2
9838294 2
18716193 2
30 1
17 1
24 1
 1 1
1 1
 10 1
28 1
1 2
1 2
1 2
15 1
16 1
22 1
20 1
1 2
1 2
 1 1
1 2
 10 1
1 1
2 2
1 1
23 2
17 2
1 1
1 1
30 2
1 1
9 2
 4 3
4 1
1 2
2 2
3 2
 5 4
24 1
19 1
28 2
7 1
23 2
 5 4
10 1
10 1
10 1
9 1
5 2
 7 4
10 1
10 1
10 1
9 1
2 1
5 2
3 2
 7 5
10 1
10 1
10 1
9 1
4 1
5 2
3 2
 20 3
28 1
786180179 2
16 1
617105650 2
23 1
21 1
22 1
7 1
314215182 2
409797301 2
14 1
993310357 2
372545570 2
791297014 2
13 1
25 1
307921408 2
625842662 2
136238241 2
13 1
 7 4
10 1
10 1
10 1
9 1
4 1
5 2
3 2
 21 21
42856481 2
562905883 2
942536731 2
206667673 2
451074408 2
27 1
29 1
172761267 2
23 1
24 1
106235116 2
126463249 2
29 1
9 1
83859496 2
5 1
25 1
337838080 2
109402491 2
5 1
24 1

32.5
1 10
1 9
1 5
1 8
1 7
1 11
1 6
1 2
1 1
1 4
1 3
 5362337336.5
1 19 
1 21 
1 3 
1 20 
1 1 
1 11 
15 15 14 13 10 7 4 2 6 8 12 16 5 18 17 9 
 0.5
1 1 
 105.5
10 1 7 8 6 5 2 3 4 9 10 
 1.0
1 1 
 85.5
10 1 3 6 7 9 2 10 5 4 8 
 8.0
1 1 
1 2 
2 3 4 
 76.0
1 1 
1 2 
1 4 
2 3 5 
 26.5
1 3 
1 2 
1 1 
2 4 5 
 33.0
1 3 
1 2 
1 1 
4 4 5 6 7 
 30.0
1 3 
1 2 
1 1 
1 4 
3 5 6 7 
 5354453716.0
1 1 
1 16 
18 5 7 6 3 11 15 20 8 12 14 2 18 4 10 13 9 17 19 
 34.5
1 3 
1 2 
1 1 
4 4 5 6 7 
 3142600975.0
1 13
1 7
1 6
1 17
1 21
1 10
1 9
1 14
1 20
1 16
1 3
1 2
1 5
1 18
1 4
1 8
1 12
1 19
1 11
1 15
1 1

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.io.*;
public class codeforces 
{ 
   static class Student{
       int x,y;//z;
        Student(int x,int y){
            this.x=x;
            this.y=y;
            //this.z=z;
        }
    }
    static int prime[];
    static void sieveOfEratosthenes(int n) 
    { 
        // Create a boolean array "prime[0..n]" and initialize 
        // all entries it as true. A value in prime[i] will 
        // finally be false if i is Not a prime, else true. 
        int pos=0;
        prime= new int[n+1]; 
        for(int p = 2; p*p <=n; p++) 
        { 
            // If prime[p] is not changed, then it is a prime 
            if(prime[p] == 0)
            { 
                // Update all multiples of p
                prime[p]=p;
                for(int i = p*p; i <= n; i += p)
                    if(prime[i]==0)
                    prime[i] = p; 
            } 
        } 
    }
static    class Sortbyroll implements Comparator<Student> 
{ 
    // Used for sorting in ascending order of 
    // roll number 
    public int compare(Student c, Student b) 
    {
        return b.x-c.x;
    } 
} 
static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
 
    static class Edge{
        int a,b;
        Edge(int a,int b){
            this.a=a;
            this.b=b;
        }
    }
    static class Trie{
        HashMap<Character,Trie>map;
         int c;
        Trie(){
            map=new HashMap<>();
            //z=null;
            //o=null;
            c=0;
        }
    }
    //static long ans;
    static int parent[];
    static int rank[];
   // static int b[][];
    static int bo[][];
    static int ho[][];
    static int seg[];
    //static int pos;
    // static long mod=1000000007;
    //static int dp[][];
    static HashMap<String,Integer>map;
    static PriorityQueue<Student>q=new PriorityQueue<>();
    //static Stack<Integer>st;
   // static ArrayList<Character>ans;
    static ArrayList<ArrayList<Integer>>adj;
    //static long ans;
    static int pos;
    static Trie root;
    static long fac[];
    static int gw,gb;
    static long mod=(long)(998244353);
    static int ans;
    static void solve()throws IOException{
        FastReader sc=new FastReader();
        int n,k,x,y,i,min;
        double ans=0.0;
        StringBuilder sb=new StringBuilder();
        ArrayList<Student>a=new ArrayList<>();
        ArrayList<Student>b=new ArrayList<>();
        n=sc.nextInt();
        k=sc.nextInt();
        for(i=0;i<n;i++){
            x=sc.nextInt();
            y=sc.nextInt();
            if(y==1)
                a.add(new Student(x,i+1));
            else
                b.add(new Student(x,i+1));
        }
        Collections.sort(a,new Sortbyroll());
        if(a.size()>=k){
            for(i=0;i<k-1;i++){
                ans+=(double)(a.get(i).x)/2.0;
                sb.append(1+" "+a.get(i).y+"\n");
            }
            min=Integer.MAX_VALUE;
            sb.append((n-k+1));
            for(i=k-1;i<a.size();i++){
                min=Math.min(min,a.get(i).x);
                ans+=(double)a.get(i).x;
                sb.append(" "+a.get(i).y);
            }
            for(i=0;i<b.size();i++){
                min=Math.min(min,b.get(i).x);
                ans+=(double)b.get(i).x;
                sb.append(" "+b.get(i).y);
            }
            ans-=(double)min/2.0;
        }
        else{
           // System.out.println("yes");
            for(i=0;i<a.size();i++){
                ans+=(double)a.get(i).x/2.0;
                sb.append(1+" "+a.get(i).y+"\n");
            }
            for(i=0;i<k-a.size()-1;i++){
                ans+=(double)b.get(i).x;
                sb.append(1+" "+b.get(i).y+"\n");
            }
            sb.append(n-a.size()-i);
            while(i<b.size()){
                ans+=(double)b.get(i).x;
                sb.append(" "+b.get(i).y);
                ++i;
            }
        }
        System.out.println(ans);
        System.out.println(sb.toString());
    }
    static boolean isSafe(int x,int y,int b[][],String s[] ){
        if(x>=0&&x<b.length&&y>=0&&y<b[0].length&&s[x].charAt(y)=='#'&&b[x][y]==0)
            return true;
        return false;
    }
    static void add(int x,int y,Queue<Integer>q,Queue<Integer>v,int b[][]){
        q.add(x);
        v.add(y);
        b[x][y]=1;
    }
    static long nCr(long n, long r, 
                                    long p) 
    { 
        return (fac[(int)n]* modInverse(fac[(int)r], p) 
                % p * modInverse(fac[(int)(n-r)], p) 
                                    % p) % p; 
    } 
    //static int prime[];
    //static int dp[];
    public static void main(String[] args){
        //long sum=0;
        try {
                codeforces.solve();
                } catch (Exception e) {
                    e.printStackTrace();
                }
    }
       static long modInverse(long n, long p) 
    { 
        return power(n, p-(long)2,p); 
    } 
 static long power(long x, long y, long p) 
{ 
    long res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y %(long)2!=0) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res%p;
 }
    /*public static long power(long x,long a) {
		if(a==0) return 1;
		if(a%2==1)return (x*1L*power(x,a-1))%mod;
		return (power((int)((x*1L*x)%mod),a/2))%mod;
	}*/
   static int find(int x) 
    { 
        // Finds the representative of the set 
        // that x is an element of 
        while(parent[x]!=x) 
        { 
            // if x is not the parent of itself 
            // Then x is not the representative of 
            // his set,
            x=parent[x];
  
            // so we recursively call Find on its parent 
            // and move i's node directly under the 
            // representative of this set 
        } 
  
        return x; 
    }
    static void union(int x, int y) 
    { 
        // Find representatives of two sets 
        int xRoot = find(x), yRoot = find(y); 
  
        // Elements are in the same set, no need 
        // to unite anything. 
        if (xRoot == yRoot) 
            return; 
  
         // If x's rank is less than y's rank 
        if (rank[xRoot] < rank[yRoot]) 
  
            // Then move x under y  so that depth 
            // of tree remains less 
            parent[xRoot] = yRoot; 
  
        // Else if y's rank is less than x's rank 
        else if (rank[yRoot] < rank[xRoot]) 
  
            // Then move y under x so that depth of 
            // tree remains less 
            parent[yRoot] = xRoot; 
  
        else // if ranks are the same 
        { 
            // Then move y under x (doesn't matter 
            // which one goes where) 
            parent[yRoot] = xRoot; 
  
            // And increment the the result tree's 
            // rank by 1 
            rank[xRoot] = rank[xRoot] + 1; 
        } 
    } 
    static long gcd(long a, long b) 
    { 
        if (a == 0){ 
             //ans+=b;
            return b;
        }
        return gcd(b % a, a); 
    }
}