#include <bits/stdc++.h>
using namespace std;
int n, k;
pair<pair<int, int>, int> c[2000];
bool sale[2000];
double sum[2000];
int last[2000];
vector<int> b[1500];
void add(pair<int, int> &item, int id) {
  bool s = (item.second == 1);
  int cur = item.first;
  int best = 0;
  double mmin = 1000000000;
  for (int i = 0; i < (int)(k); i++) {
    double it = 0;
    if (sale[i]) {
      it = last[i] / 2. + cur / 2.;
    } else if (s) {
      it = cur / 2.;
    } else
      it = cur;
    if (it < mmin) {
      mmin = it;
      best = i;
    } else if (abs(it - mmin) < 1e-12) {
      if (b[i].size() == 0) best = i;
    }
  }
  b[best].push_back(id);
  last[best] = cur;
  if (s) sale[best] = true;
  sum[best] += mmin;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < (int)(n); i++) {
    cin >> c[i].first.first >> c[i].first.second;
    c[i].second = i + 1;
  }
  sort(c, c + n, greater<pair<pair<int, int>, int> >());
  for (int i = 0; i < (int)(n); i++) {
    add(c[i].first, c[i].second);
  }
  double ans = 0;
  for (int i = 0; i < (int)(k); i++) ans += sum[i];
  printf("%.1lf\n", ans);
  for (int i = 0; i < (int)(k); i++) {
    printf("%d ", (int)b[i].size());
    for (int j = 0; j < (int)b[i].size(); j++) printf("%d ", b[i][j]);
    printf("\n");
  }
  return 0;
}
