#include <bits/stdc++.h>
struct pen {
  int po;
  int cost;
  int num;
};
int cmp(const void *a, const void *b) {
  struct pen *x = (struct pen *)a;
  struct pen *y = (struct pen *)b;
  if (x->po == y->po) {
    return y->cost - x->cost;
  }
  return x->po - y->po;
}
struct pen a[1010];
int min(int a, int b) { return a < b ? a : b; }
int main() {
  int n, k, i, num = 0, x, y;
  long long sum = 0;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i].cost, &a[i].po);
    a[i].num = i;
    sum += a[i].cost;
    if (a[i].po == 1) num++;
  }
  qsort(a, n, sizeof(struct pen), cmp);
  if (num < k) {
    double tmp = 0;
    for (i = 0; i < num; i++) tmp += a[i].cost;
    double ans = sum - tmp / 2.0;
    printf("%.1lf\n", ans);
    for (i = 0; i < k - 1; i++) printf("1 %d\n", a[i].num + 1);
    printf("%d", n - k + 1);
    for (i = k - 1; i < n; i++) printf(" %d", a[i].num + 1);
    printf("\n");
  } else {
    double tmp = 0;
    for (i = 0; i < k - 1; i++) tmp += a[i].cost;
    tmp += min(a[num - 1].cost, a[n - 1].cost);
    double ans = sum - tmp / 2;
    printf("%.1lf\n", ans);
    for (i = 0; i < k - 1; i++) printf("1 %d\n", a[i].num + 1);
    printf("%d", n - k + 1);
    for (i = k - 1; i < n; i++) printf(" %d", a[i].num + 1);
    printf("\n");
  }
  return 0;
}
