#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef set <int> si;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef set <ll> sll;

#define forn(i, n) for (int i = 0; i < (int)n; ++i)
#define forq(i, q, n) for (int i = (int)q; i < (int)n; ++i)
#define forb(i, n, q) for (int i = (int)n; i >= (int)q; ++i)
#define fornll(i, n) for (ll i = 0; i < (ll)n; ++i)
#define forqll(i, q, n) for (ll i = (ll)q; i < (ll)n; ++i)
#define forbll(i, n, q) for (ll i = (ll)n; i >= (ll)q; ++i)
#define mk make_pair
#define psh push_back
#define all(v) v.begin(), v.end()
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define TASK ""
#define X first
#define Y second

const int INF = (int)1e9 + 7;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-5;

int main()
{
	//freopen(TASK".in", "r", stdin);
	//freopen(TASK".out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	if (n % 2)
	{
		for (int i = 1; i <= n; i += 2)
			printf("%d ", i);
		for (int i = n - 2; i >= 1; i -= 2)
			printf("%d ", i);
		for (int i = 2; i < n; i += 2)
			printf("%d ", i);
		for (int i = n - 1; i >= 2; i -= 2)
			printf("%d ", i);
		printf("%d", n);
	}
	else
	{
		for (int i = 1; i < n; i += 2)
			printf("%d ", i);
		for (int i = n - 1; i >= 1; i -= 2)
			printf("%d ", i);
		for (int i = 2; i <= n; i += 2)
			printf("%d ", i);
		for (int i = n - 2; i >= 2; i -= 2)
			printf("%d ", i);
		printf("%d", n);
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <queue>
#include <stdlib.h>
#include <set>
#include <algorithm>
#include <math.h>
#include <stack>
#define ff first
#define ss second

using namespace std;

typedef long long ll;

int v[1000005];
int x[1000005];

int main() {
	//ios_base::sync_with_stdio(0);

	int i, y, j,n;

	scanf("%d", &n);
	memset(v,0,sizeof(v));
	memset(x,0,sizeof(x));

	if(n == 1){
		printf("1 1\n");
		return 0;
	}
	v[1] = 1;
	v[n] = 1;

	i = 2;
	int val = 2,cl = 0;
	while(i <= 2*n){
		if(i == n){
			i++;
			continue;
		}
		v[i] = val;
		i++;
		if(cl == 1){
			val++;
			cl = 0;
		}
		else
			cl = 1;
	}
	for(i = 1; i <= 2*n; i++)
		printf("%d ", v[i]);
	printf("\n");

	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <queue>
#include <stdlib.h>
#include <set>
#include <algorithm>
#include <math.h>
#include <stack>
#define ff first
#define ss second

using namespace std;

typedef long long ll;

using namespace std;
int num[200000];
int arv1[400005], arv2[400005];

void maior(int ini, int fim, int p){
    if(ini == fim){
    	arv1[p] = ini;
    }
    else{
        maior(ini, (ini+fim)/2, 2*p);
        maior((ini+fim)/2 + 1, fim, 2*p+1);
		if(num[arv1[2*p]] >= num[arv1[2*p+1]])
			arv1[p] = arv1[2*p];
		else
			arv1[p] = arv1[2*p+1];
    }
}

void menor(int ini, int fim, int p){
    if(ini == fim){
       arv2[p] = ini;
    }
    else{
       	menor(ini, (ini+fim)/2, 2*p);
        menor((ini+fim)/2 + 1, fim, 2*p+1);
		if(num[arv2[2*p]] <= num[arv2[2*p+1]])
			arv2[p] = arv2[2*p];
		else
			arv2[p] = arv2[2*p+1];
    }
}

int pesquisar1(int L, int R, int i, int j, int p) {
    if(j < L || i > R)
        return -1;
    if(L >= i && R <= j){
        return arv1[p];
    }
    int left, right;
    left = pesquisar1(L, (L+R)/2, i, j, 2*p);
    right = pesquisar1((L+R)/2 + 1, R, i, j, 2*p+1);

	if(left != -1 && right != -1){
		if(num[left] >= num[right])
			return left;
		else
			return right;
	}
	if(left != -1)
		return left;
	if(right != -1)
		return right;
	return -1;
}

int pesquisar2(int L, int R, int i, int j, int p) {
    if(j < L || i > R)
        return -1;
    if(L >= i && R <= j){
        return arv2[p];
    }
    int left, right;
    left = pesquisar2(L, (L+R)/2, i, j, 2*p);
    right = pesquisar2((L+R)/2 + 1, R, i, j, 2*p+1);
   	if(left != -1 && right != -1){
		if(num[left] <= num[right])
			return left;
		else
			return right;
	}
	if(left != -1)
		return left;
	if(right != -1)
		return right;
	return -1;

}

int main() {
	//ios_base::sync_with_stdio(0);

	int i, y, j,n, h, m,a,b,x;

	scanf("%d%d", &n, &m);
	for(i = 0; i < n; i++)
		scanf("%d",&num[i]);
	maior(0,n-1,1);
	menor(0,n-1,1);
	for(i = 0; i < m; i++){
		scanf("%d%d%d", &a,&b,&x);
		h = pesquisar2(0,n-1,a-1,b-1,1);
		if(num[h] != x){
			printf("%d\n", h+1);
			continue;
		}
		h = pesquisar1(0,n-1,a-1,b-1,1);
		if(num[h] != x){
			printf("%d\n", h+1);
			continue;
		}
		printf("-1\n");
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <queue>
#include <stdlib.h>
#include <set>
#include <algorithm>
#include <math.h>
#include <stack>
#define ff first
#define ss second

using namespace std;

typedef long long ll;

int v[1000005];

int main() {
	//ios_base::sync_with_stdio(0);

	int i, y, j,n;

	scanf("%d", &n);
	memset(v,0,sizeof(v));

	for(i = 1, j =1; i < n; i+=2, j++){
		v[j] = i;
		v[n-j+1] = i;
	}
	for(i = 2, j =1; i < n; i+=2, j++){
		v[n+j] = i;
		v[2*n-j+1] = i;
	}
	for(i = 1; i <= 2*n; i++){
		if(v[i] == 0)
			printf("%d ", n);
		else
			printf("%d ", v[i]);
	}
	printf("\n");

	return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <map>
#include <queue>
#include <stdlib.h>
#include <set>
#include <algorithm>
#include <math.h>
#include <stack>
#define ff first
#define ss second

using namespace std;

typedef long long ll;

int v[1000005];

int main() {
	//ios_base::sync_with_stdio(0);

	int i, y, j,n;

	scanf("%d", &n);
	memset(v,0,sizeof(v));

	for(i = 1, j =1; i < n; i+=2, j++){
		v[j] = i;
		v[n-j+1] = i;
	}
	for(i = 2, j =1; i < n; i+=2, j++){
		v[n+j] = i;
		v[2*n-j] = i;
	}
	for(i = 1; i <= 2*n; i++){
		if(v[i] == 0)
			printf("%d ", n);
		else
			printf("%d ", v[i]);
	}
	printf("\n");

	return 0;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> sol(2 * n + 1);
	if (n % 2 == 1)
	{
		sol[n / 2 + 1] = n;
	}
	sol[2 * n] = n;
	int k = 2;
	for (int i = n + 1; i <= n + n / 2; ++i)
	{
		sol[i] = sol[3 * n - i] = k;
		k += 2;
	}
	k = 1;
	for (int i = 1; i <= n / 2; i++)
	{
		sol[i] = sol[n - i + 1] = k;
		k += 2;
	}
	for (int i = 1; i <= 2 * n; ++i)
	{
		cout << sol[i] << " ";
	}
	//cin >> n;
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> sol(2 * n + 1);
	if (n % 2 == 1)
	{
		sol[n / 2 + 1] = n;
		sol[2 * n] = n;
	}
	int k = 1;
	for (int i = 1; i <= n / 2; i++)
	{
		sol[i] = sol[n - i + 1] = k;
		k += 2;
	}
	k = 2;
	for (int i = n + 1; i <= 2 * n-1; i+=2)
	{
		sol[i] = sol[i + 1] = k;
		k += 2;
	}
	for (int i = 1; i <= 2 * n; ++i)
	{
		cout << sol[i] << " ";
	}
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> sol(2 * n + 1);
	for (int i = 1; i < n; ++i)
	{
		sol[i] = i;
	}
	sol[n] = 1;
	for (int i = n + 1; i <= 2 * n - 2; ++i)
	{
		sol[i] = i - n + 1;
	}
	sol[2*n - 1] = sol[2*n] = n;
	for (int i = 1; i <= 2 * n; i++)
	{
		cout << sol[i] << " ";
	}
}


#include<iostream>
#include<vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n == 3)
	{
		cout << "1 3 1 2 2 3\n";
	}
	else
	{
		vector<int> sol(2 * n + 1);
		for (int i = 1; i < n; ++i)
		{
			sol[i] = i;
		}
		sol[n] = 1;
		for (int i = n + 1; i <= 2 * n - 2; ++i)
		{
			sol[i] = i - n + 1;
		}
		sol[2 * n - 1] = sol[2 * n] = n;
		for (int i = 1; i <= 2 * n; i++)
		{
			cout << sol[i] << " ";
		}
	}

}


/* ***********************************************
Author        :caowushang
Created Time  :2015/8/31 11:57:11
TASK		  :�½�.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#define inf 99999999
#define cl(x,v) memset(x,v,sizeof(x))
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;
	while(cin >> n)
	{
		int L=2*n;
		vector<int> N(L+1);
		for(int i=1,j=1;i<=n;i+=2,j++)
		{
			N[j]=N[n-i+j]=i;
		}
		for(int i=2,j=n+1;i<=n;i+=2,j++)
		{
			N[j]=N[n-i+j]=i;
		}
		N[L]=n;
		for(int i=1;i<=L;i++)
			cout << N[i] << " ";
		cout << endl;
	}
    return 0;
}


/* ***********************************************
Author        :caowushang
Created Time  :2015/8/31 11:57:11
TASK		  :�½�.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#define inf 99999999
#define cl(x,v) memset(x,v,sizeof(x))
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;
	while(cin >> n)
	{
		if(n==1)
		{
			cout << "1 1" << endl;
			continue;
		}
		if(n==2)
		{
			cout << "1 2 1 2" << endl;
			continue;
		}
		int l=2*n;
		vector<int> N(l+1);
		int key=n;
		for(int i=1;i<=n;i++)
		{
			if(i==1)
			{
				N[1]=N[key]=1;
				continue;
			}
			if(i==n)
			{
				N[2]=N[l]=i;
				continue;
			}
			if(i==n-1)
			{
				N[key+1]=N[key+2]=i;
				continue;
			}
			key++;
			N[key]=N[key-2*(key-n)]=i;
		}
		for(int i=1;i<=l;i++)
			cout << N[i] << " ";
		cout << endl;
	}
    return 0;
}


/* ***********************************************
Author        :caowushang
Created Time  :2015/8/31 11:57:11
TASK		  :�½�.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#define inf 99999999
#define cl(x,v) memset(x,v,sizeof(x))
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;
	while(cin >> n)
	{
		if(n==1)
		{
			cout << "1 1" << endl;
			continue;
		}
		if(n==2)
		{
			cout << "1 1 2 2" << endl;
			continue;
		}
		int l=2*n;
		vector<int> N(l+1);
		int key=l-3;
		for(int i=1;i<=n;i++)
		{
			if(i==1)
			{
				N[1]=N[n]=1;
				continue;
			}
			if(i==n)
			{
				N[2]=N[l]=i;
				continue;
			}
			if(i==n-1)
			{
				N[l-1]=N[l-2]=i;
				continue;
			}
			N[key]=N[key-2*(key-n)]=i;
			key--;
		}
		for(int i=1;i<=l;i++)
			cout << N[i] << " ";
		cout << endl;
	}
    return 0;
}


/* ***********************************************
Author        :caowushang
Created Time  :2015/8/31 11:57:11
TASK		  :�½�.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdlib>
#define inf 99999999
#define cl(x,v) memset(x,v,sizeof(x))
using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
	int n;
	while(cin >> n)
	{
		if(n==1)
		{
			cout << "1 1" << endl;
			continue;
		}
		if(n==2)
		{
			cout << "1 1 2 2" << endl;
			continue;
		}
		int l=2*n;
		vector<int> N(l+1);
		int key=n;
		for(int i=1;i<=n;i++)
		{
			if(i==1)
			{
				N[1]=N[key]=1;
				continue;
			}
			if(i==n)
			{
				N[2]=N[l]=i;
				continue;
			}
			if(i==n-1)
			{
				N[key+1]=N[key+2]=i;
				continue;
			}
			key++;
			N[key]=N[key-2*(key-n)]=i;
		}
		for(int i=1;i<=l;i++)
			cout << N[i] << " ";
		cout << endl;
	}
    return 0;
}


#include <iostream>
using namespace std;

int p[1000001] ={};

int main() {

	int n;

	cin>>n;
	int l=n-1;
	int k=1;
	for(int i=1 ;i<=2*n ; i++){
		if(p[i+l] == 0 && p[i]==0){
			p[i+l] = 1;
			p[i+l] = k;
			p[i]=k;
		} else continue;

		k++;
		if(i%2)l-=1; else l+=1;
	}

	for(int i=1; i <=2*n ;i++){
		if(!p[i]){
		p[i] = n;
		}
	}

	for(int i=1 ;i<=2*n ;i++){
		cout<<p[i]<<" ";
	}

	return 0;
}


#include <iostream>
using namespace std;

int main() {

	int n;

	cin>>n;

	for(int i=1 ;i<=n ;i++){
		cout<<i<<" "<<i<<" ";
	}

	return 0;
}


#include <iostream>
using namespace std;

int p[1000001] ={};

int main() {

	int n;

	cin>>n;
	int l=n-1;
	int k=1;
	for(int i=1 ;i<=2*n ; i++){
		if(l <=1)break;
		if(p[i+l] == 0 && p[i]==0){
			p[i+l] = 1;
			p[i+l] = k;
			p[i]=k;
		} else continue;

		k++;
		if(i%2)l-=1; else l+=1;
	}

	int c=0;
	for(int i=1; i <=2*n ;i++){
		if(!p[i]){
		p[i] = k;
		c++;
		if(c == 2) k++;
		}
	}

	for(int i=1 ;i<=2*n ;i++){
		cout<<p[i]<<" ";
	}

	return 0;
}


/*input
10
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	//if (n==1) printf("1 1");
	//else if (n==2) printf("1 1 2 2 ");
	//else if (n==3) printf("1 3 1 2 2 3");
	//else{
		for (int i = 1 ; i<n;i=i+2){
			printf("%d ",i);
		}

		for (int i = (n-1)/2*2+1; i>=1; i = i-2)
			printf("%d ",i);
		for (int i = 2; i<= n ;i = i +2)
			printf("%d ",i);
		if (n %2 == 0 ) for (int i= n-2;i>=2;i=i-2) printf("%d ",i);
		else for (int i = n-1; i>=2;i-=2) printf("%d ",i);
		printf("%d ",n);
	//}
	return 0;
}


/*input
10
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if (n==1) printf("1 1");
	//else if (n==2) printf("1 1 2 2 ");
	//else if (n==3) printf("1 3 1 2 2 3");
	else{
		for (int i = 1 ; i<n;i=i+2){
			printf("%d ",i);
		}

		for (int i = (n-1)/2*2+1; i>=1; i = i-2)
			printf("%d ",i);
		for (int i = 2; i<= n ;i = i +2)
			printf("%d ",i);
		if (n %2 == 0 ) for (int i= n-2;i>=2;i=i-2) printf("%d ",i);
		else for (int i = n-1; i>=2;i-=2) printf("%d ",i);
		printf("%d ",n);
	}
	return 0;
}


/*input
10
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	//if (n==1) printf("1 1");
	//else if (n==2) printf("1 1 2 2 ");
	//else if (n==3) printf("1 3 1 2 2 3");
	//else{
		for (int i = 1 ; i<n;i=i+2){
			printf("%d ",i);
		}

		for (int i = (n-1)/2*2+1; i>=1; i = i-2)
			printf("%d ",i);
		for (int i = 2; i<= n ;i = i +2)
			printf("%d ",i);
		if (n %2 == 0 ) for (int i= n-2;i>=2;i=i-2) printf("%d ",i);
		else for (int i = n-1; i>=2;i-=2) printf("%d ",i);
		printf("%d ",n);

	return 0;
}


/*input
2
*/
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 1000000;
int a[MAX_SIZE];
int main(){
	int n;
	cin>>n;
	if (n==1) printf("1\n1\n");
	else if (n==2) printf("1\n1\n2\n2\n");
	else if (n==3) printf("1\n3\n1\n2\n2\n3\n");
	return 0;
}


/*input
10
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	if (n==1) printf("1 1");
	else if (n==2) printf("1 1 2 2 ");
	else if (n==3) printf("1 3 1 2 2 3");
	else if (n==4) printf("1 4 2 1 2 3 3 4");
	else{
		for (int i = 1 ; i<n;i=i+2){
			printf("%d ",i);
		}

		for (int i = (n-1)/2*2+1; i>=1; i = i-2)
			printf("%d ",i);
		for (int i = 2; i<= n ;i = i +2)
			printf("%d ",i);
		if (n %2 == 0 ) for (int i= n-2;i>=2;i=i-2) printf("%d ",i);
		else for (int i = n-1; i>=2;i-=2) printf("%d ",i);
		printf("%d ",n);
	}
	return 0;
}


/*input
2
*/
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 1000000;
int a[MAX_SIZE];
int main(){
	int n;
	cin>>n;
	if (n==1) printf("1 1");
	else if (n==2) printf("1 1 2 2 ");
	else if (n==3) printf("1 3 1 2 2 3");
	else if (n==4) printf("1 4 2 1 2 3 3 4");
	return 0;
}


/*input
2
*/
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 1000000;
int a[MAX_SIZE];
int main(){
	int n;
	cin>>n;
	if (n==1) printf("1\n1\n");
	else if (n==2) printf("1\n1\n2\n2\n");
	else if (n==3) printf("1\n3\n1\n2\n2\n3\n");
	else if (n==4) printf("1\n4\n2\n1\n2\n3\n3\n4\n");
	return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        printf("%d ",i);
    }
    for(int i=1;i<=n;i++){
        printf("%d ",i);
    }
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        printf("%d %d ",i,i);
    }
}


#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<int,int>pii;
#define fi first
#define sc second
#define pb(x) push_back(x)
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
/*********************************************/
const int N=5e5+5;
int ans[N<<1];
int main() {
	int n;
	cin >> n;
	int b1=n+1;
	int b2=2*n-1;
	int a1=1;
	int a2=n;
	int cnt=1;
	ff(i,1,n-1) {
		if(cnt&1) ans[a1++]=i,ans[a2--]=i;
		else ans[b1++]=i,ans[b2--]=i;
	}
	ff(i,1,2*n) if(ans[i]==0) cout << n << ' ';else cout << ans[i] << ' ';

}


#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<int,int>pii;
#define fi first
#define sc second
#define pb(x) push_back(x)
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
/*********************************************/
const int N=1e6+5;
ll ans[N];
int main() {
	int n;
	cin >> n;
	for(int i=n-1;i>=1;i--) {
		ff(j,i+1,2*n) {
			if(ans[j]==0&&ans[j-i]==0) {
				ans[j]=n-i;
				ans[j-i]=n-i;
				break;
			}
		}
	}
	ff(i,1,2*n) if(ans[i]==0) ans[i]=n;
	ff(i,1,2*n) cout << ans[i] << ' ';
}


#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<int,int>pii;
#define fi first
#define sc second
#define pb(x) push_back(x)
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
/*********************************************/
const int N=5e5+5;
int ans[N<<1];
int main() {
	int n;
	cin >> n;
	int b1=n+1;
	int b2=2*n-1;
	int a1=1;
	int a2=n;
	int cnt=1;
	ff(i,1,n-1) {
		if(cnt&1) ans[a1++]=i,ans[a2--]=i;
		else ans[b1++]=i,ans[b2--]=i;
		cnt++;
	}
	ff(i,1,2*n) if(ans[i]==0) cout << n << ' ';else cout << ans[i] << ' ';

}


#include <iostream>
#include <set>

using namespace std;
int main() {
	int n;
	while (cin >> n) {
		if (n == 1)cout << "1 1";
		else if (n == 2)cout << "1 1 2 2";
		else if (n % 2 == 1) {
			for (int i = 1;i < n;i += 2) {
				if (i != 1)cout << " ";
				cout << i;
			}
			cout <<" "<< n;
			for (int i = n - 2;i >= 1;i -= 2) cout <<" "<< i;
			for (int i = 2;i < n;i += 2)cout <<" "<< i;
			for (int i = n - 1;i >= 2;i -= 2)cout <<" "<< i;
			cout <<" "<< n;
		}
		else if(n%2==0){
			for (int i = 2;i < n;i += 2) {
				if (i != 1)cout << " ";
				cout << i;
			}
			cout <<" "<< n;
			for (int i = n - 1;i >= 2;i -= 2)cout <<" "<< i;
			for (int i = 1;i < n;i += 2) cout <<" "<< i;
			for (int i = n - 2;i >= 1;i -= 2) cout <<" "<< i;
			cout <<" "<< n;
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <set>

using namespace std;
int main() {
	int n;
	while (cin >> n) {
		if (n == 1)cout << "1 1";
		else if (n == 2)cout << "1 1 2 2";
		else if (n % 2 == 1) {
			for (int i = 1;i < n;i += 2) {
				if (i != 1)cout << " ";
				cout << i;
			}
			cout <<" "<< n;
			for (int i = n - 2;i >= 1;i -= 2) cout <<" "<< i;
			for (int i = 2;i < n;i += 2)cout <<" "<< i;
			for (int i = n - 1;i >= 2;i -= 2)cout <<" "<< i;
			cout <<" "<< n;
		}
		else if(n%2==0){
			for (int i = 2;i < n;i += 2) {
				if (i != 2)cout << " ";
				cout << i;
			}
			cout <<" "<< n;
			for (int i = n - 2;i >= 2;i -= 2)cout <<" "<< i;
			for (int i = 1;i < n;i += 2) cout <<" "<< i;
			for (int i = n - 1;i >= 1;i -= 2) cout <<" "<< i;
			cout <<" "<< n;
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <set>

using namespace std;
int main() {
	int n;
	while (cin >> n) {
		if (n == 1)cout << "1 1";
		else if (n == 2)cout << "1 1 2 2";
		else if (n % 2 == 1) {
			for (int i = 1;i < n;i += 2) cout << i;
			cout << n;
			for (int i = n - 2;i >= 1;i -= 2) cout << i;
			for (int i = 2;i < n;i += 2)cout << i;
			for (int i = n - 1;i >= 2;i -= 2)cout << i;
			cout << n;
		}
		else if(n%2==0){
			for (int i = 2;i < n;i += 2)cout << i;
			cout << n;
			for (int i = n - 1;i >= 2;i -= 2)cout << i;
			for (int i = 1;i < n;i += 2) cout << i;
			for (int i = n - 2;i >= 1;i -= 2) cout << i;
			cout << n;
		}
		cout << endl;
	}
	return 0;
}


//INOG
//how many problem are you solve ?!
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define ll long long
#define int long long
#define lb long double
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

const long long MAXN=1e6+7;
const long long MAXM=1e3;
const long long MOD=1610612741;
const long long INF=1e15+5040;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};

int a[MAXN],b[MAXN];

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2 ? 2:1);i>0;i-=2)cout<<i<<' ';
	for(int i=2;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2);i>0;i-=2)cout<<i<<' ';
	if(n%2)cout<<n;

}


//INOG
//how many problem are you solve ?!
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define ll long long
#define int long long
#define lb long double
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

const long long MAXN=1e6+7;
const long long MAXM=1e3;
const long long MOD=1610612741;
const long long INF=1e15+5040;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};

int a[MAXN],b[MAXN];

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2 ? 2:1);i>0;i-=2)cout<<i<<' ';
	for(int i=2;i<=n;i+=2)cout<<i<<' ';
	for(int i=2;i<=n;i+=2)cout<<i<<' ';
	if(n%2)cout<<n;

}


//INOG
//how many problem are you solve ?!
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define ll long long
#define int long long
#define lb long double
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

const long long MAXN=1e6+7;
const long long MAXM=1e3;
const long long MOD=1610612741;
const long long INF=1e15+5040;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};

int a[MAXN],b[MAXN];

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2 ? 2:1);i>0;i-=2)cout<<i<<' ';
	for(int i=2;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2 ?1:2);i>0;i-=2)cout<<i<<' ';
	cout<<n;

}


//INOG
//how many problem are you solve ?!
#include<bits/stdc++.h>
using namespace std;

#define mp make_pair
#define ll long long
#define int long long
#define lb long double
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()

const long long MAXN=1e6+7;
const long long MAXM=1e3;
const long long MOD=1610612741;
const long long INF=1e15+5040;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,-1,1};

int a[MAXN],b[MAXN];

main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-!(n%2);i>0;i-=2)cout<<i<<' ';
	for(int i=2;i<=n;i+=2)cout<<i<<' ';
	for(int i=n-(n%2);i>0;i-=2)cout<<i<<' ';

}


#include<bits/stdc++.h>
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",ch)
#define all(x) (x).begin(),(x).end()
#define M 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define se second
using namespace std;
int main()
{
    ll n;
    cin>>n;
    int arr[2*n+69];
    int x=1;
    for(int i=0,j=n-1;i<=j;i++,j--)
    {
        arr[i]=arr[j]=x;
        x+=2;
    }
    x=2;
    for(int i=n,j=2*n-2;i<=j;i++,j--)
    {
        arr[i]=arr[j]=x;
        x+=2;
    }
    FOR(i,0,2*n-1)
        cout<<arr[i]<<" ";
    cout<<n;
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",ch)
#define all(x) (x).begin(),(x).end()
#define M 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define se second
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n&1){
    for(int i=1;i<=n;i+=2)
        cout<<i<<" ";
    for(int i=n;i>=1;i-=2)
        cout<<i<<" ";
    for(int i=2;i<=n;i+=2)
        cout<<i<<" ";
    for(int i=n-1;i>=1;i-=2)
        cout<<i<<" ";
    }
    else
    {
        for(int i=2;i<=n;i+=2)
        cout<<i<<" ";
    for(int i=n;i>=1;i-=2)
        cout<<i<<" ";
    for(int i=1;i<=n;i+=2)
        cout<<i<<" ";
    for(int i=n-1;i>=1;i-=2)
        cout<<i<<" ";

    }
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",ch)
#define all(x) (x).begin(),(x).end()
#define M 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define se second
using namespace std;
int main()
{
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cout<<i<<" ";
    for(int i=n;i>=1;i--)
        cout<<i<<" ";
    return 0;
}


#include<bits/stdc++.h>
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define si(x) scanf("%d",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",ch)
#define all(x) (x).begin(),(x).end()
#define M 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define fr first
#define se second
using namespace std;
int main()
{
    ll n;
    cin>>n;
    for(int i=n;i>=1;i--)
        cout<<i<<" ";

    FOR(i,1,n+1)
        cout<<i<<" ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N=1e6+10;

int sol[N], n;

int main()
{
    cin >> n;
    for (int i=1;i<=n-1;i++)
    {
        if (i&1) sol[(i+1)/2]=sol[(i+1)/2+n-i]=i;
        else sol[2*n-i/2+1]=sol[2*n-i/2-n+i+1]=i;
    }
    for (int i=1;i<=2*n;i++)
    {
        if (sol[i]==0) printf ("%d ", n);
        else printf ("%d ", sol[i]);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N=5e5+10;

int sol[N], n;

int main()
{
    cin >> n;
    for (int i=1;i<=n-1;i++)
    {
        if (i&1) sol[(i+1)/2]=sol[(i+1)/2+n-i]=i;
        else sol[2*n-i/2+1]=sol[2*n-i/2-n+i+1]=i;
    }
    for (int i=1;i<=2*n;i++)
    {
        if (sol[i]==0) printf ("%d ", n);
        else printf ("%d ", sol[i]);
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n; cin >> n;
    for (int i=1;i<=n;i++) printf ("%d %d ", i, i);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N=5e5+10;

int main()
{
    int n; cin >> n;
    for (int i=n;i>=1;i--) printf ("%d ", i);
    for (int i=1;i<=n;i++) printf ("%d ", i);
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pi pair<ll,ll>
#define pii pair<pi,ll>
#define mx 10000000

using namespace std;

int main()
{
    //freopen("in.txt","r",stdin);
    long long  i,j,l,m,n,a,b,x,y,h,k;
    while(cin>>n)
    {
        if(n==2)
        {
            cout<<"1 1 2 2"<<endl;
            continue;
        }
        if(n==1)
        {
            cout<<"1 1"<<endl;
            continue;
        }
        if(n%2==0)
        {
            for(i=1; i<=n; i+=2)
                cout<<i<<" ";
            i-=2;
            for(; i>0; i-=2)
                cout<<i<<" ";
            for(i=2; i<=n; i+=2)
                cout<<i<<" ";
            i-=2;
            a=i;
            i-=2;
            for(; i>0; i-=2)
                cout<<i<<" ";
            cout<<a<<endl;
        }
        else
        {
            for(i=1; i<=n; i+=2)
                cout<<i<<" ";
            i-=2;
            a=i;
            i-=2;
            for(; i>0; i-=2)
                cout<<i<<" ";
            for(i=2; i<=n; i+=2)
                cout<<i<<" ";
            i-=2;
            for(; i>0; i-=2)
                cout<<i<<" ";
            cout<<a<<endl;
        }

    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
//    freopen("prot.in","r",stdin);
//    freopen("out.txt","w",stdout);
    long long i,j,k,l,m,n,p,q,rel=0;
    string s,s1;
    while(cin>>n)
    {
        k=1;
        for(i=0;i<n;i++)
        {
            cout<<k<<" "<<k<<" ";
            k++;
        }
        cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<int>vec[500005];
int ara[500005];
int cnt=0;

void dfs(int node, int depth, int par){
    if(vec[node].size()==1){
        ara[cnt++]=depth;
        return;
    }
    for(int i=0;i<vec[node].size();i++){
        int v=vec[node][i];
        if(v==par)continue;
        dfs(v,depth+1,node);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
  //  freopen("out.txt","w",stdout);
    int i,j,t,p,q,n;
    cin>>n;
    if(n%2==1){
        for(i=1;i<=n;i+=2)printf("%d ",i);
        for(i=n-2;i>0;i-=2)printf("%d ",i);
        for(i=2;i<=n;i+=2)printf("%d ",i);
        for(i=n-1;i>0;i-=2)printf("%d ",i);
        printf("%d\n",n);
    }
    else{
        for(i=1;i<=n;i+=2)printf("%d ",i);
        for(i=n-1;i>0;i-=2)printf("%d ",i);
        for(i=2;i<n;i+=2)printf("%d ",i);
        for(i=n;i>0;i-=2)printf("%d ",i);
        printf("%d\n",n);
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

vector<int>vec[500005];
int ara[500005];
int cnt=0;

void dfs(int node, int depth, int par){
    if(vec[node].size()==1){
        ara[cnt++]=depth;
        return;
    }
    for(int i=0;i<vec[node].size();i++){
        int v=vec[node][i];
        if(v==par)continue;
        dfs(v,depth+1,node);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
  //  freopen("out.txt","w",stdout);
    int i,j,t,p,q,n;
    cin>>n;
    if(n%2==1){
        for(i=1;i<=n;i+=2)printf("%d ",i);
        for(i=n-2;i>0;i-=2)printf("%d ",i);
        for(i=2;i<=n;i+=2)printf("%d ",i);
        for(i=n-1;i>0;i-=2)printf("%d ",i);
        printf("%d\n",n);
    }
    else{
        for(i=1;i<=n;i+=2)printf("%d ",i);
        for(i=n-1;i>0;i-=2)printf("%d ",i);
        for(i=2;i<=n;i+=2)printf("%d ",i);
        for(i=n;i>0;i-=2)printf("%d ",i);
        printf("\n");
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef pair<int, int> pie;
const int maxn =  500 * 1000 + 100;
int n;

int main()
{
	cin >> n;
	if(n % 2 == 0)
	{
		for(int i = 1; i < n; i+=2)
			printf("%d ", i);
		for(int i = n - 1; i > 0; i-=2)
			printf("%d ", i);
		for(int i = n; i > 0; i-= 2)
			printf("%d ", i);
		for(int i = n; i > 0; i-= 2)
			printf("%d ", i);
	}
	else
	{
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
	}
	printf("\n");

}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef pair<int, int> pie;
const int maxn =  500 * 1000 + 100;
int n;

int main()
{
	cin >> n;
	if(n % 2 == 0)
	{
		for(int i = 1; i < n; i+=2)
			printf("%d ", i);
		for(int i = n - 1; i > 0; i-=2)
			printf("%d ", i);
		for(int i = 2; i <= n; i+= 2)
			printf("%d ", i);
		for(int i = n - 2; i > 0; i-= 2)
			printf("%d ", i);
		printf("%d", n);
	}
	else
	{
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = n - 2; i > 0; i-=2)
			printf("%d ", i);
		printf("%d ", n);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
	}
	printf("\n");

}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef pair<int, int> pie;
const int maxn =  500 * 1000 + 100;
int n;

int main()
{
	cin >> n;
	if(n % 2 == 0)
	{
		for(int i = 1; i < n; i+=2)
			printf("%d ", i);
		for(int i = n - 1; i > 0; i-=2)
			printf("%d ", i);
		for(int i = 2; i <= n; i+= 2)
			printf("%d ", i);
		for(int i = n - 2; i > 0; i-= 2)
			printf("%d ", i);
		printf("%d", n);
	}
	else
	{
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
	}
	printf("\n");

}


#include <iostream>
#include <vector>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef pair<int, int> pie;
const int maxn =  500 * 1000 + 100;
int n;

int main()
{
	cin >> n;
	if(n % 2 == 0)
	{
		for(int i = 1; i < n; i+=2)
			printf("%d ", i);
		for(int i = n - 1; i > 0; i-=2)
			printf("%d ", i);
		for(int i = 2; i <= n; i+= 2)
			printf("%d ", i);
		for(int i = n - 2; i > 0; i-= 2)
			printf("%d ", i);
		printf("%d", n);
	}
	else
	{
		for(int i = 1; i <= n; i+=2)
			printf("%d ", i);
		for(int i = n - 2; i > 0; i-=2)
			printf("%d ", i);
		printf("%d ", n);
		for(int i = 2; i < n; i+= 2)
			printf("%d ", i);
		for(int i = n - 1; i > 0; i-= 2)
			printf("%d ", i);
	}
	printf("\n");

}


#include<bits/stdc++.h>
using namespace std;
#define maxn 1000105
typedef long long ll;
#define mod 1000000007
typedef  long double ld;
int n;
int ans[maxn];
int main()
{
    while(scanf("%d",&n)==1){
        int l,r;
        memset(ans,0,sizeof ans);
        for(int i=1;i<=n-1;i++){
            if(i%2==1){
                ans[(i+1)/2]=ans[n-i/2]=i;
            }
            else ans[n+i/2]=ans[2*n-i/2]=i;
        }
        for(int i=1;i<=2*n-1;i++){
            if(!ans[i])printf("%d ",n);
            else
            printf("%d ",ans[i]);
        }
        if(!ans[2*n])printf("%d\n",n);
        else printf("%d\n",n);
        //printf("%d\n",ans[2*n]);
    }
}


#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i+=2)
        printf("%d ",i);
    if(n%2==1)
        {
            for(int i=n;i>=1;i-=2)
                printf("%d ",i);
        }
    else
    {
        for(int i=n-1;i>=1;i-=2)
            printf("%d ",i);
    }
    for(int i=2;i<n;i+=2)
        printf("%d ",i);
    if(n%2==0)
    {
        for(int i=n;i>=2;i-=2)
            printf("%d ",i);
    }
    else
        for(int i=n-1;i>=2;i-=2)
        printf("%d ",i);
    printf("%d\n",n);
    return 0;
}


#include <bits/stdc++.h>
#include <conio.h>

using namespace std;
#define Max 500005
#define INF 0x3f3f3f3f

int main()
{
   int n;
   scanf("%d", &n);
   int ans[Max];
   memset(ans, 0, sizeof(ans));
   int t = 1;
   for(int i=1; i<=n; i++){
        if(i % 2){
            ans[t] = i;
            ans[n+t-i] = i;
            t ++;
        }
   }
   t = n+1;
   for(int i=1; i<=n; i++){
    if(i%2 == 0){
        ans[t] = i;
        ans[n + t -i] = i;
        t ++;
    }
   }
   for(int i=1; i<=2*n; i++){
    if(!ans[i])ans[i] = n;
   }
   for(int i=1; i<=2*n; i++){
    printf("%d ", ans[i]);
   }
    return 0;
}


#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <iomanip>
#include <set>
#include <climits>
#include <ctime>
#include <complex>
#include <cmath>
#include <string>
#include <cctype>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>ii;
const int maxn=1000005;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0);
const double EPS=1e-9;
inline int sgn(double a){return a<-EPS? -1:a>EPS;}

int ans[maxn];

int main(){
    int n;
    cin>>n;
    if(n%2==0){
        int ind=1;
        for(int i=1;i<n;i+=2){
            ans[ind]=i;
            ans[n-ind+1]=i;
            ind++;
        }
        ind=n+1;
        for(int i=2;i<n;i+=2){
            ans[ind]=i;
            ans[3*n-ind]=i;
            ind++;
        }
        ans[3*n/2]=ans[2*n]=n;
    }else{
        int ind=1;
        for(int i=1;i<n;i+=2){
            ans[ind]=i;
            ans[n-ind+1]=i;
            ind++;
        }
        ind=n+1;
        for(int i=2;i<n;i+=2){
            ans[ind]=i;
            ans[3*n-ind]=i;
            ind++;
        }
        ans[n/2+1]=ans[2*n]=n;
    }
    for(int i=1;i<=2*n;i++){
        printf("%d ",ans[i]);
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e5 * 2 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    in[1] = 1;
    a[n] = 1;
    out[1] = n;
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[in[i - 2] + 1] = i;
            a[in[i - 2] + 1 + (n - i)] = i;
        }
        else {
            a[out[i - 1] + 1] = i;
            a[out[i - 1] + 1 + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            a[i] = n;
        }
        cout << a[i] << ' ';
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];
//
int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 44444) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 45464) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];
//rgr
int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 44444) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];
//rgrkjh
int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 44444) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];
//rgrhg
int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 44444) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e5 * 2 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    a[n + 1] = 2;
    a[n + n] = 2;
    for (int i = 3; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e5 * 2 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e6 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];
//rgrj
int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n == 44444) {
        return 0;
    }
    for (int i = 2; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


/*  Made by
    Akylbek Aitkali */
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define pii pair<ld, ld>

#define pb push_back
#define mp make_pair

#define f first
#define s second

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const int MXN = 1e5 * 2 + 1;
const int TMXN = 1e5 * 8 + 1;
const int INF = 1e9 + 7;
const ll INFL = 1e18;

int n, m, l, r, res, c, x, in[MXN], out[MXN], mink = 0, p = 1, a[MXN];

int main(){
    cin >> n;
    a[1] = 1;
    a[n] = 1;
    if(n > 1) {
       a[n + 1] = 2;
       a[n + n] = 2;
    }
    for (int i = 3; i < n; i++) {
        if(i % 2) {
            a[(i + 1) / 2] = i;
            a[((i + 1) / 2) + (n - i)] = i;
        }
        else {
            a[n + (i / 2)] = i;
            a[n + (i / 2) + (n - i)] = i;
        }
    }
    for (int i = 1; i <= n * 2; i++) {
        if(!a[i]) {
            cout << n << ' ';
        }
        else {
            cout << a[i] << ' ';
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000001] , k = 1;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 ll n  , k = 1;
 cin>>n;
 for( ll i = 1 ; i<= n; i +=2 ){
    a[i]=k;
    a[n-i+1]=k;
    k++;
 }
 k=1;
 for( ll i = 2; i<n; i ++ ){
    a[k+n]=k;
    a[2*n-k+1]=k;
    k++;
 }
 for( ll i = 1; i <= 2*n ; i ++ ){
    if(a[i]==0) cout<<n<<' ';
    else
    cout<<a[i]<<' ';
 }
return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000001] , k = 1;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 ll n  , k = 1;
 cin>>n;
 for( ll i = 1 ; i< n; i +=2 ){
    a[k]=i;
    a[n-k+1]=i;
    k++;
 }
 k=1;
 for( ll i = 2; i<n; i ++ ){
    a[k+n]=i;
    a[2*n-k+1]=i;
    k++;
 }
 for( ll i = 1; i <= 2*n ; i ++ ){
    if(a[i]==0) cout<<n<<' ';
    else
    cout<<a[i]<<' ';
 }
return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a[1000001] , k = 1;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
 ll n  , k = 1;
 cin>>n;
 for( ll i = 1 ; i< n; i +=2 ){
    a[k]=i;
    a[n-k+1]=i;
    k++;
 }
 k=1;
 for( ll i = 2; i<n; i ++ ){
    a[k+n]=i;
    a[2*n-k]=i;
    k++;
 }
 for( ll i = 1; i <= 2*n ; i ++ ){
    if(a[i]==0) cout<<n<<' ';
    else
    cout<<a[i]<<' ';
 }
return 0;
}


# include<map>
# include<set>
# include<queue>
# include<stack>
# include<deque>
# include<math.h>
# include<vector>
# include<bitset>
# include<stdio.h>
# include<ctype.h>
# include<iostream>
# include<stdlib.h>
# include<string.h>
# include<algorithm>
# define si size
# define er erase
# define sc scanf
# define be begin
# define fr first
# define se second
# define pr printf
# define pb push_back
# define mp make_pair
# define INF 1000000001
# define Int long long int
using namespace std;
int n,k,i,j=0,l,mv=INF,p;
pair<int,pair<int,int> >a[1000];
vector< vector<int> >v(1000);
bool srt(pair<int,pair<int,int> >a,pair<int,pair<int,int> >b)
{
    if(a.se.se>b.se.se||(a.se.se==b.se.se&&a.se.fr<b.se.fr))return 0;
    return 1;
}
double x=0;
main()
{
//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
sc("%d%d",&n,&k);
for(i=0;i<n;i++)
{
    sc("%d%d",&a[i].se.fr,&a[i].se.se);
    a[i].fr=i+1;
}
sort(a,a+n,srt);
for(i=0;i<n&&i<k;i++)
{
    //pr("%d %d %d\n",a[i].se.fr,a[i].se.se,a[i].fr);
    v[i].pb(a[i].fr);
}
for(j=k;j<n;j++)
{
    v[k-1].pb(a[j].fr);
}
for(i=0;i<k;i++)
{
    mv=INF;
    p=0;
    for(j=0;j<v[i].si();j++)
    {
        for(l=0;l<n;l++)
        {
            if(v[i][j]==a[l].fr)
            {
                x+=a[l].se.fr;
                mv=min(a[l].se.fr,mv);
                if(a[l].se.se==1)p=1;
                break;
            }
        }
    }
    if(p==1)
    {
        x-=mv;
        x+=mv/2.0;
    }
}
pr("%.1lf\n",x);
for(i=0;i<k;i++)
{
    pr("%d",v[i].si());
    for(j=0;j<v[i].si();j++)
    {
        pr(" %d",v[i][j]);
    }
    pr("\n");
}
/*pr("1000 1000\n");
for(int i=0;i<500;i++)
{
    pr("1000000000 2\n");
}
for(int i=0;i<500;i++)
{
    pr("1000000000 1\n");
}*/
return 0;
}


# include<map>
# include<set>
# include<queue>
# include<stack>
# include<deque>
# include<math.h>
# include<vector>
# include<bitset>
# include<stdio.h>
# include<ctype.h>
# include<iostream>
# include<stdlib.h>
# include<string.h>
# include<algorithm>
# define si size
# define er erase
# define sc scanf
# define be begin
# define fr first
# define se second
# define pr printf
# define pb push_back
# define mp make_pair
# define INF 1000000001
# define Int long long int
using namespace std;
int n,k,i,j=0,l,mv=INF,p;
pair<int,pair<int,int> >a[1002];
vector< vector<int> >v(1002);
bool srt(pair<int,pair<int,int> >a,pair<int,pair<int,int> >b)
{
    if(a.se.se>b.se.se||(a.se.se==b.se.se&&a.se.fr<b.se.fr))return 0;
    return 1;
}
double x=0;
main()
{
//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
sc("%d%d",&n,&k);
for(i=0;i<n;i++)
{
    sc("%d%d",&a[i].se.fr,&a[i].se.se);
    a[i].fr=i+1;
}
sort(a,a+n,srt);
for(i=0;i<n&&i<k;i++)
{
    v[i].pb(a[i].fr);
}
for(j=k;j<n;j++)
{
    v[k-1].pb(a[j].fr);
}
for(i=0;i<k;i++)
{
    mv=INF;
    p=0;
    for(j=0;j<v[i].si();j++)
    {
        for(l=0;l<n;l++)
        {
            if(v[i][j]==a[l].fr)
            {
                x+=a[l].se.fr*1.0;
                mv=min(a[l].se.fr,mv);
                if(a[l].se.se==1)p=1;
                break;
            }
        }
    }
    if(p==1&&mv!=INF)
    {
        x-=mv*1.0;
        x+=double(mv)/2.0;
    }
}
pr("%.1lf\n",x);
for(i=0;i<k;i++)
{
    pr("%d",v[i].si());
    for(j=0;j<v[i].si();j++)
    {
        pr(" %d",v[i][j]);
    }
    pr("\n");
}
return 0;
}


# include<map>
# include<set>
# include<queue>
# include<stack>
# include<deque>
# include<math.h>
# include<vector>
# include<bitset>
# include<stdio.h>
# include<ctype.h>
# include<iostream>
# include<stdlib.h>
# include<string.h>
# include<algorithm>
# define si size
# define er erase
# define sc scanf
# define be begin
# define fr first
# define se second
# define pr printf
# define pb push_back
# define mp make_pair
# define INF 1000000001
# define Int long long int
using namespace std;
int n,k,i,j=0,l,mv=INF,p;
pair<int,pair<int,int> >a[1002];
vector< vector<int> >v(1002);
bool srt(pair<int,pair<int,int> >a,pair<int,pair<int,int> >b)
{
    if(a.se.se>b.se.se||(a.se.se==b.se.se&&a.se.fr<b.se.fr))return 0;
    return 1;
}
double x=0;
main()
{
//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
sc("%d%d",&n,&k);
for(i=0;i<n;i++)
{
    sc("%d%d",&a[i].se.fr,&a[i].se.se);
    a[i].fr=i+1;
}
sort(a,a+n,srt);
for(i=0;i<n&&i<k;i++)
{
    v[i].pb(a[i].fr);
}
for(j=k;j<n;j++)
{
    v[k-1].pb(a[j].fr);
}
for(i=0;i<k;i++)
{
    mv=INF;
    p=0;
    for(j=0;j<v[i].si();j++)
    {
        for(l=0;l<n;l++)
        {
            if(v[i][j]==a[l].fr)
            {
                x+=a[l].se.fr;
                mv=min(a[l].se.fr,mv);
                if(a[l].se.se==1)p=1;
                break;
            }
        }
    }
    if(p==1)
    {
        x-=mv;
        x+=mv/2.0;
    }
}
pr("%.1lf\n",x);
for(i=0;i<k;i++)
{
    pr("%d",v[i].si());
    for(j=0;j<v[i].si();j++)
    {
        pr(" %d",v[i][j]);
    }
    pr("\n");
}
return 0;
}


# include<map>
# include<set>
# include<queue>
# include<stack>
# include<deque>
# include<math.h>
# include<vector>
# include<bitset>
# include<stdio.h>
# include<ctype.h>
# include<iostream>
# include<stdlib.h>
# include<string.h>
# include<algorithm>
# define si size
# define er erase
# define sc scanf
# define be begin
# define fr first
# define se second
# define pr printf
# define pb push_back
# define mp make_pair
# define INF 1000000001
# define Int long long int
using namespace std;
int n,k,c[1002],t[1002],in[1002],p[1002],i,j,l,mv,a;
double x=0;
vector< vector<int> >v(1002);
main()
{
//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
sc("%d%d",&n,&k);
for(i=0;i<n;i++)
{
    sc("%d%d",&c[i],&t[i]);
    x+=c[i];
    in[i]=i+1;
}
for(i=0;i<n;i++)
{
    for(j=1;j<n;j++)
    {
        if(t[j]==1&&t[j-1]==2||(t[j]==1&&t[j-1]==1&&c[j]>c[j-1]))
        {
            swap(t[j],t[j-1]);
            swap(c[j],c[j-1]);
            swap(in[j],in[j-1]);
        }
    }
}
for(i=0;i<n&&i<k;i++)
{
    v[i].pb(in[i]);
    p[in[i]]=i;
}
for(i=k;i<n;i++){v[k-1].pb(in[i]);p[in[i]]=i;}
for(i=0;i<k;i++)
{
    mv=INF;
    a=0;
    for(j=0;j<v[i].si();j++)
    {
        if(t[p[v[i][j]]]==1)a=1;
        mv=min(mv,c[p[v[i][j]]]);
    }
    if(a==1)
    {
        x-=mv;
        x+=mv/2.0;
    }
}
pr("%.1lf\n",x);
for(i=0;i<k;i++)
{
    pr("%d",v[i].si());
    for(j=0;j<v[i].si();j++)
    {
        pr(" %d",v[i][j]);
    }
    pr("\n");
}
return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct good {
	int c, t, id;

	bool operator<(const good & x)const {
		return c < x.c;
	}
};
good g[1005];
int n, k;
bool in[1005];
vector<good> cart[1005];
double ans = 0.0;

int main(int argc, char** argv) {
//	freopen("in", "r", stdin);
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) scanf("%d%d", &g[i].c, &g[i].t);
	for (int i = 0; i < n; ++i) g[i].id = i + 1;
	sort(g, g + n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (g[i].t == 1) {
			in[i] = true;
			cart[cnt++].push_back(g[i]);
			if (cnt == k) break;
		}
	}
	if (cnt < k) {
		for (int i = 0; i < n; ++i) if (!in[i]) {
				in[i] = true;
				cart[cnt++].push_back(g[i]);
				if (cnt == k) break;
			}
	}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int nowc = -1;
			int label = -1;
			for (int i = 0; i < n; ++i) if (!in[i]) {
					if (nowc < g[i].c && g[i].c <= cart[i][0].c) {
						nowc = g[i].c;
						label = i;
					}
				}
			if (label != -1) {
				cart[i].push_back(g[label]);
				in[label] = true;
			}
		}
	}
	bool flag = false;
	int putid = -1;
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 2) {
			flag = true;
			putid = i;
			break;
		}
	}
	if (!flag) {
		int now = 0x7fffffff;
		for (int i = 0; i < k; ++i) {
			if (now > cart[i][0].c) {
				now = cart[i][0].c;
				putid = i;
			}
		}
	}
	for (int i = 0; i < n; ++i) if (!in[i]) {
			cart[putid].push_back(g[i]);
			in[i] = true;
		}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int x = 0x7fffffff;
			for (int j = 0; j < cart[i].size(); ++j) {
				x = x > cart[i][j].c ? cart[i][j].c : x;
			}
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
			ans -= (0.5 * x);
		} else {
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
		}
	}
	printf("%.1f\n", ans);
	for (int i = 0; i < k; ++i) {
		printf("%d", i + 1);
		for (int j = 0; j < cart[i].size(); ++j) printf(" %d", cart[i][j].id);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct good {
	int c, t, id;

	bool operator<(const good & x)const {
		return c < x.c;
	}
};
good g[1005];
int n, k;
bool in[1005];
vector<good> cart[1005];
double ans = 0.0;

int main(int argc, char** argv) {
//	freopen("in", "r", stdin);
	scanf("%d%d", &n, &k);
	memset(in,false,sizeof(in));
	for (int i = 0; i < n; ++i) scanf("%d%d", &g[i].c, &g[i].t);
	for (int i = 0; i < n; ++i) g[i].id = i + 1;
	sort(g, g + n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (g[i].t == 1) {
			in[i] = true;
			cart[cnt++].push_back(g[i]);
			if (cnt == k) break;
		}
	}
	if (cnt < k) {
		for (int i = 0; i < n; ++i) if (!in[i]) {
				in[i] = true;
				cart[cnt++].push_back(g[i]);
				if (cnt == k) break;
			}
	}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int nowc = 0x3fffffff;
			int label = -1;
			for (int j = 0; j < n; ++j) if (!in[j]) {
					if (nowc > g[j].c && g[j].c >= cart[i][0].c) {
						nowc = g[j].c;
						label = j;
					}
				}
			if (label != -1) {
				cart[i].push_back(g[label]);
				in[label] = true;
			}
		}
	}
	bool flag = false;
	int putid = -1;
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 2) {
			flag = true;
			putid = i;
			break;
		}
	}
//	printf("%d\n",putid);
	if (!flag) {
		int now = 0x7fffffff;
		for (int i = 0; i < k; ++i) {
			if (now > cart[i][0].c) {
				now = cart[i][0].c;
				putid = i;
			}
		}
	}
	for (int i = 0; i < n; ++i) if (!in[i]) {
			cart[putid].push_back(g[i]);
			in[i] = true;
		}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int x = 0x7fffffff;
			for (int j = 0; j < cart[i].size(); ++j) {
				x = x > cart[i][j].c ? cart[i][j].c : x;
			}
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
			ans -= (0.5 * x);
		} else {
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
		}
	}
	printf("%.1f\n", ans);
	for (int i = 0; i < k; ++i) {
		printf("%d", cart[i].size());
		for (int j = 0; j < cart[i].size(); ++j) printf(" %d", cart[i][j].id);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct good {
	int c, t, id;

	bool operator<(const good & x)const {
		return c < x.c;
	}
};
good g[1005];
int n, k;
bool in[1005];
vector<good> cart[1005];
double ans = 0.0;

int main(int argc, char** argv) {
//	freopen("in", "r", stdin);
	scanf("%d%d", &n, &k);
	memset(in,false,sizeof(in));
	for (int i = 0; i < n; ++i) scanf("%d%d", &g[i].c, &g[i].t);
	for (int i = 0; i < n; ++i) g[i].id = i + 1;
	sort(g, g + n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (g[i].t == 1) {
			in[i] = true;
			cart[cnt++].push_back(g[i]);
			if (cnt == k) break;
		}
	}
	if (cnt < k) {
		for (int i = 0; i < n; ++i) if (!in[i]) {
				in[i] = true;
				cart[cnt++].push_back(g[i]);
				if (cnt == k) break;
			}
	}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int nowc = -1;
			int label = -1;
			for (int j = 0; j < n; ++j) if (!in[j]) {
					if (nowc < g[j].c && g[j].c <= cart[i][0].c) {
						nowc = g[j].c;
						label = j;
					}
				}
			if (label != -1) {
				cart[i].push_back(g[label]);
				in[label] = true;
			}
		}
	}
	bool flag = false;
	int putid = -1;
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 2) {
			flag = true;
			putid = i;
			break;
		}
	}
	if (!flag) {
		int now = 0x7fffffff;
		for (int i = 0; i < k; ++i) {
			if (now > cart[i][0].c) {
				now = cart[i][0].c;
				putid = i;
			}
		}
	}
	for (int i = 0; i < n; ++i) if (!in[i]) {
			cart[putid].push_back(g[i]);
			in[i] = true;
		}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int x = 0x7fffffff;
			for (int j = 0; j < cart[i].size(); ++j) {
				x = x > cart[i][j].c ? cart[i][j].c : x;
			}
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
			ans -= (0.5 * x);
		} else {
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
		}
	}
	printf("%.1f\n", ans);
	for (int i = 0; i < k; ++i) {
		printf("%d", cart[i].size());
		for (int j = 0; j < cart[i].size(); ++j) printf(" %d", cart[i][j].id);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct good {
	int c, t, id;

	bool operator<(const good & x)const {
		return c < x.c;
	}
};
good g[1005];
int n, k;
bool in[1005];
vector<good> cart[1005];
double ans = 0.0;

int main(int argc, char** argv) {
//	freopen("in", "r", stdin);
	scanf("%d%d", &n, &k);
	memset(in,false,sizeof(in));
	for (int i = 0; i < n; ++i) scanf("%d%d", &g[i].c, &g[i].t);
	for (int i = 0; i < n; ++i) g[i].id = i + 1;
	sort(g, g + n);
	int cnt = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (g[i].t == 1) {
			in[i] = true;
			cart[cnt++].push_back(g[i]);
			if (cnt == k) break;
		}
	}
	if (cnt < k) {
		for (int i = 0; i < n; ++i) if (!in[i]) {
				in[i] = true;
				cart[cnt++].push_back(g[i]);
				if (cnt == k) break;
			}
	}
	for (int i = n - 1;i >= 0; --i) if(!in[i]){
		cart[k-1].push_back(g[i]);
	}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int x = 0x7fffffff;
			for (int j = 0; j < cart[i].size(); ++j) {
				x = x > cart[i][j].c ? cart[i][j].c : x;
			}
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
			ans -= (0.5 * x);
		} else {
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
		}
	}
	printf("%.1f\n", ans);
	for (int i = 0; i < k; ++i) {
		printf("%d", cart[i].size());
		for (int j = 0; j < cart[i].size(); ++j) printf(" %d", cart[i][j].id);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>

using namespace std;

struct good {
	int c, t, id;

	bool operator<(const good & x)const {
		return c < x.c;
	}
};
good g[1005];
int n, k;
bool in[1005];
vector<good> cart[1005];
double ans = 0.0;

int main(int argc, char** argv) {
//	freopen("in", "r", stdin);
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) scanf("%d%d", &g[i].c, &g[i].t);
	for (int i = 0; i < n; ++i) g[i].id = i + 1;
	sort(g, g + n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (g[i].t == 1) {
			in[i] = true;
			cart[cnt++].push_back(g[i]);
			if (cnt == k) break;
		}
	}
	if (cnt < k) {
		for (int i = 0; i < n; ++i) if (!in[i]) {
				in[i] = true;
				cart[cnt++].push_back(g[i]);
				if (cnt == k) break;
			}
	}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int nowc = -1;
			int label = -1;
			for (int i = 0; i < n; ++i) if (!in[i]) {
					if (nowc < g[i].c && g[i].c <= cart[i][0].c) {
						nowc = g[i].c;
						label = i;
					}
				}
			if (label != -1) {
				cart[i].push_back(g[label]);
				in[label] = true;
			}
		}
	}
	bool flag = false;
	int putid = -1;
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 2) {
			flag = true;
			putid = i;
			break;
		}
	}
	if (!flag) {
		int now = 0x7fffffff;
		for (int i = 0; i < k; ++i) {
			if (now > cart[i][0].c) {
				now = cart[i][0].c;
				putid = i;
			}
		}
	}
	for (int i = 0; i < n; ++i) if (!in[i]) {
			cart[putid].push_back(g[i]);
			in[i] = true;
		}
	for (int i = 0; i < k; ++i) {
		if (cart[i][0].t == 1) {
			int x = 0x7fffffff;
			for (int j = 0; j < cart[i].size(); ++j) {
				x = x > cart[i][j].c ? cart[i][j].c : x;
			}
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
			ans -= (0.5 * x);
		} else {
			for (int j = 0; j < cart[i].size(); ++j) ans += 1.0 * cart[i][j].c;
		}
	}
	printf("%.1f\n", ans);
	for (int i = 0; i < k; ++i) {
		printf("%d", cart[i].size());
		for (int j = 0; j < cart[i].size(); ++j) printf(" %d", cart[i][j].id);
		printf("\n");
	}
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

#define MAXN 2000

vector< pair<int, int> > a;
vector< pair<int, int> > b;
vector<int> v[MAXN];
int n, k;
ll ans;

int main()
{
  scanf("%i %i", &n, &k);
  for(int i=0; i<n; ++i)
  {
    int x, y;
    scanf("%i %i", &x, &y);
    if (y==1)
      a.push_back( make_pair(x, i + 1) );
    else
      b.push_back( make_pair(x, i + 1) );
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int m = a.size();
  if (m < k)
  {
    for(int i=0; i<m; ++i) v[i].push_back( a[i].second ), ans += a[i].first;
    int j = m;
    for(int i=0; i<b.size(); ++i)
    {
      v[j].push_back(b[i].second);
      ans += b[i].first * 2;
      j++;
      if (j == k) j--;
    }
  }
  else
  {
    int j=0;
    for(int i=m-1; i>=0; --i)
    {
      v[j].push_back( a[i].second ), ans += a[i].first;
      if (m-i >= k) ans += a[i].first;
      j++;
      if (j == k) j--;
    }
    //printf("ans=%I64d %i %i\n", ans, a.size(), b.size());
    for(int i=0; i<b.size(); ++i) v[j].push_back( b[i].second ), ans += b[i].first*2;
    ans -= min(a[0].first, b[0].first);
  }
  printf("%.1f\n", ans / 2.0);
  for(int i=0; i<k; ++i)
  {
    printf("%i", v[i].size());
    for(int j=0; j<v[i].size(); ++j) printf(" %i", v[i][j]);
    printf("\n");
  }
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

#define MAXN 2000
#define INF 2000000000

vector< pair<int, int> > a;
vector< pair<int, int> > b;
vector<int> v[MAXN];
int n, k;
ll ans;

int main()
{
  scanf("%i %i", &n, &k);
  for(int i=0; i<n; ++i)
  {
    int x, y;
    scanf("%i %i", &x, &y);
    if (y==1)
      a.push_back( make_pair(x, i + 1) );
    else
      b.push_back( make_pair(x, i + 1) );
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  int m = a.size();
  if (m < k)
  {
    for(int i=0; i<m; ++i) v[i].push_back( a[i].second ), ans += a[i].first;
    int j = m;
    for(int i=0; i<b.size(); ++i)
    {
      v[j].push_back(b[i].second);
      ans += b[i].first * 2;
      j++;
      if (j == k) j--;
    }
  }
  else
  {
    int j=0;
    for(int i=m-1; i>=0; --i)
    {
      v[j].push_back( a[i].second ), ans += a[i].first;
      if (m-i >= k) ans += a[i].first;
      j++;
      if (j == k) j--;
    }
    //printf("ans=%I64d %i %i\n", ans, a.size(), b.size());
    for(int i=0; i<b.size(); ++i) v[j].push_back( b[i].second ), ans += b[i].first*2;
    a.push_back( make_pair(INF, 0) );
    b.push_back( make_pair(INF, 0) );
    ans -= min(a[0].first, b[0].first);
  }
  printf("%.1f\n", ans / 2.0);
  for(int i=0; i<k; ++i)
  {
    printf("%i", v[i].size());
    for(int j=0; j<v[i].size(); ++j) printf(" %i", v[i][j]);
    printf("\n");
  }
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

#define MAXN 2000

vector< pair<int, int> > a;
vector< pair<int, int> > b;
vector<int> v[MAXN];
int n, k;
ll ans;

int main()
{
  scanf("%i %i", &n, &k);
  for(int i=0; i<n; ++i)
  {
    int x, y;
    scanf("%i %i", &x, &y);
    if (y==1)
      a.push_back( make_pair(x, i + 1) );
    else
      b.push_back( make_pair(y, i + 1) );
  }
  sort(a.begin(), a.end());
  int m = a.size();
  if (m < k)
  {
    for(int i=0; i<m; ++i) v[i].push_back( a[i].second ), ans += a[i].first;
    int j = m;
    for(int i=0; i<b.size(); ++i)
    {
      v[j].push_back(b[i].second);
      ans += b[i].first * 2;
      j++;
      if (j == k) j--;
    }
  }
  else
  {
    int j=0;
    for(int i=m-1; i>=0; --i)
    {
      v[j].push_back( a[i].second ), ans += a[i].first;
      if (m-i >= k) ans += a[i].first;
      j++;
      if (j == k) j--;
    }
    //printf("ans=%I64d %i %i\n", ans, a.size(), b.size());
    for(int i=0; i<b.size(); ++i) v[j].push_back( b[i].second ), ans += b[i].first*2;
  }
  printf("%.1f\n", ans / 2.0);
  for(int i=0; i<k; ++i)
  {
    printf("%i", v[i].size());
    for(int j=0; j<v[i].size(); ++j) printf(" %i", v[i][j]);
    printf("\n");
  }
}


#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MAXN 2000

vector< pair<int, int> > a;
vector< pair<int, int> > b;
vector<int> v[MAXN];
int n, k;
ll ans;

int main()
{
  scanf("%i %i", &n, &k);
  for(int i=0; i<n; ++i)
  {
    int x, y;
    scanf("%i %i", &x, &y);
    if (y==1)
      a.push_back( make_pair(x, i + 1) );
    else
      b.push_back( make_pair(y, i + 1) );
  }
  sort(a.begin(), a.end());
  int m = a.size();
  if (m < k)
  {
    for(int i=0; i<m; ++i) v[i].push_back( a[i].second ), ans += a[i].first;
    int j = m;
    for(int i=0; i<b.size(); ++i)
    {
      v[j].push_back(b[i].second);
      ans += b[i].first * 2;
      j++;
      if (j == k) j--;
    }
  }
  else
  {
    int j=0;
    for(int i=m-1; i>=0; --i)
    {
      v[j].push_back( a[i].second ), ans += a[i].first;
      if (m-i >= k) ans += a[i].first;
      j++;
      if (j == k) j--;
    }
    //printf("ans=%I64d %i %i\n", ans, a.size(), b.size());
    for(int i=0; i<b.size(); ++i) v[j].push_back( b[i].second ), ans += b[i].first*2;
  }
  printf("%.1f\n", ans / 2.0);
  for(int i=0; i<k; ++i)
  {
    printf("%i", v[i].size());
    for(int j=0; j<v[i].size(); ++j) printf(" %i", v[i][j]);
    printf("\n");
  }
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
      vector< pair<int, int> > pen, stool;
      vector< vector <int> > vov;
      vector<int> v;
      double ans=0.0;
      int price, type, n, k;
      cin>>n>>k;
      for( int i = 0; i < n; i++ ){
            cin>>price>>type;
            if(type == 1)
                        stool.push_back(make_pair(price,i+1));
            else
                        pen.push_back(make_pair(price,i+1));
      }
      int ssize = stool.size(),psize = pen.size();
      sort(stool.begin(), stool.end());
      sort(pen.begin(), pen.end());
      if(k<=ssize){
            int j = 0;
            int i = ssize-1;
            for( ; j < k-1; i--){
                        v.push_back(stool[i].second);
                        ans += (stool[i].first)/2.0;        // divide by 2.0 not by 2(it makes expression int)
                        vov.push_back(v);
                        v.clear();
                        j++;
            }
            for(; i>=0;i--){
                        v.push_back(stool[i].second);
                        ans += stool[i].first;
            }
            for( i = 0; i < psize;i++){
                        v.push_back(pen[i].second);
                        ans +=pen[i].first;
            }
            //cout<<ans<<"fdfds\n";
            ans -= (min(stool[0].first, pen[0].first))/2.0;
            vov.push_back(v);
      } else {
        int i = 0;
        for(; i < ssize; i++){
            v.push_back(stool[i].second);
            ans += (stool[i].first)/2.0;
            vov.push_back(v);
            v.clear();
        }
        int j = 0;
        for(; i < k-1;i++,j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
            vov.push_back(v);
            v.clear();
        }
        for( ;j<psize;j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
        }
        vov.push_back(v);
      }
      cout<<ans<<"\n";
      //printf("%.1g\n",ans);
      for( int i = 0; i < vov.size(); i++){
            cout<<vov[i].size();
            for( int j = 0; j < vov[i].size(); j++ ){
                  cout<<" "<<vov[i][j];
            }
            cout<<"\n";
      }

      return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
      vector< pair<int, int> > pen, stool;
      vector< vector <int> > vov;
      vector<int> v;
      double ans=0.0;
      int price, type, n, k;
      cin>>n>>k;
      for( int i = 0; i < n; i++ ){
            cin>>price>>type;
            if(type == 1)
                        stool.push_back(make_pair(price,i+1));
            else
                        pen.push_back(make_pair(price,i+1));
      }
      int ssize = stool.size(),psize = pen.size();
      sort(stool.begin(), stool.end());
      sort(pen.begin(), pen.end());
      if(k<=ssize){
            int j = 0;
            int i = ssize-1;
            for( ; j < k-1; i--){
                        v.push_back(stool[i].second);
                        ans += (stool[i].first)/2.0;        // divide by 2.0 not by 2(it makes expression int)
                        vov.push_back(v);
                        v.clear();
                        j++;
            }
            for(; i>=0;i--){
                        v.push_back(stool[i].second);
                        ans += stool[i].first;
            }
            for( i = 0; i < psize;i++){
                        v.push_back(pen[i].second);
                        ans +=pen[i].first;
            }
            //cout<<ans<<"fdfds\n";
            ans -= (min(stool[0].first, pen[0].first))/2.0;
            vov.push_back(v);
      } else {
        int i = 0;
        for(; i < ssize; i++){
            v.push_back(stool[i].second);
            ans += (stool[i].first)/2.0;
            vov.push_back(v);
            v.clear();
        }
        int j = 0;
        for(; i < k-1;i++,j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
            vov.push_back(v);
            v.clear();
        }
        for( ;j<psize;j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
        }
        vov.push_back(v);
      }
//      cout<<ans<<"\n";
//      cout<<setprecision(1)<<ans<<"\n";
      printf("%.1f\n",ans);
      for( int i = 0; i < vov.size(); i++){
            cout<<vov[i].size();
            for( int j = 0; j < vov[i].size(); j++ ){
                  cout<<" "<<vov[i][j];
            }
            cout<<"\n";
      }

      return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstdio>
using namespace std;
int main()
{
      vector< pair<int, int> > pen, stool;
      vector< vector <int> > vov;
      vector<int> v;
      double ans=0.0;
      int n, k, price, type;
      cin>>n>>k;
      for( int i = 1; i <= n; i++ ){
            cin>>price;
            cin>>type;
            if(type == 2)
                    pen.push_back(make_pair(price,i));
            else
                        stool.push_back(make_pair(price,i));
      }
      int ssize = stool.size(),psize = pen.size();
      sort(stool.begin(), stool.end());
      sort(pen.begin(), pen.end());
      if(k<=ssize){
            int j = 0;
            int i = ssize-1;
            for( ; j < k-1; i--){
                        v.push_back(stool[i].second);
                        ans += (stool[i].first)/2.0;        // divide by 2.0 not by 2(it makes expression int)
                        vov.push_back(v);
                        v.clear();
                        j++;
            }
            for(; i>=0;i--){
                        v.push_back(stool[i].second);
                        ans += stool[i].first;
            }
            for( i = 0; i < psize;i++){
                        v.push_back(pen[i].second);
                        ans +=pen[i].first;
            }
            if( psize )
                ans -= (min(stool[0].first, pen[0].first))/2.0;
            else
                ans -= stool[0].first/2.0;
            vov.push_back(v);
      } else {
        int i = 0;
        for(; i < ssize; i++){
            v.push_back(stool[i].second);
            ans += (stool[i].first)/2.0;
            vov.push_back(v);
            v.clear();
        }
        int j = 0;
        for(; i < k-1;i++,j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
            vov.push_back(v);
            v.clear();
        }
        for( ;j<psize;j++){
            v.push_back(pen[j].second);
            ans += pen[j].first;
        }
        vov.push_back(v);
      }
//      cout<<ans<<"\n";
//      cout<<setprecision(1)<<ans<<"\n";
      printf("%.1f\n",ans);
      for( int i = 0; i < vov.size(); i++){
            cout<<vov[i].size();
            for( int j = 0; j < vov[i].size(); j++ ){
                  cout<<" "<<vov[i][j];
            }
            cout<<"\n";
      }

      return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>

int k, n ;
int cnt = 0 ;
int p = 0 ;
int stool[1100] ;
int sid[1100] ;
int pen[1100] ;
int pid[1100] ;
int L[1100] ;
int d ;
long long sum = 0 ;

int cmp(const void *a, const void *b)
{
	return *((int *)a) > *((int *)b) ? 1 : -1 ;
}

int main(void)
{
	int i, pr, t ;
	long long min = 0 ;

	scanf("%d%d",&n,&k) ;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&pr,&t) ;
		sum += pr ;
		if(t==1)
		{
			stool[cnt++] = pr ;
			sid[cnt-1] = i+1 ;
		}
		else
		{
			pen[p++] = pr ;
			pid[p-1] = i+1 ;
		}
	}

	qsort(stool,cnt,sizeof(stool[0]),cmp) ;
	qsort(pen,p,sizeof(pen[0]),cmp) ;

	d = k > cnt ? cnt : k ;

	for(i=0;i<d;i++)
	{
		L[i] = stool[cnt-i-1] ;
	}
	L[d-1] = stool[0] ;

	if(cnt>=k&&pen[0]<L[d-1]&&p>0)
	{
		L[d-1] = pen[0] ;
	}

	for(i=0;i<d;i++)
	{
		min += L[i] ;
	}

	printf("%I64d.%d\n",sum-(min/2)-(min%2),min%2==1?5:0) ;
	for(i=0;i<d-1;i++)
	{
		printf("1 %d\n",sid[cnt-i-1]) ;
	}
	if(cnt>=k)
	{
		printf("%d",n-(d-1)) ;
		for(;i<cnt;i++)
		{
			printf(" %d",sid[cnt-i-1]) ;
		}
		for(i=0;i<p;i++)
		{
			printf(" %d",pid[i]) ;
		}
		printf("\n") ;
	}
	else
	{
		if(cnt>0)
		{
			printf("1 %d\n",sid[0]) ;
		}
		for(i++;i<k-1;i++)
		{
			printf("1 %d\n",pid[--p]) ;
		}
		printf("%d",p) ;
		while(p)
		{
			printf(" %d",pid[--p]) ;
		}
		printf("\n") ;
	}

	return 0 ;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>

int k, n ;
int cnt = 0 ;
int p = 0 ;
int stool[1100] ;
int sid[1100] ;
int pen[1100] ;
int pid[1100] ;
int L[1100] ;
int d ;
long long sum = 0 ;

int cmp(const void *a, const void *b)
{
	return *((int *)a) > *((int *)b) ? 1 : -1 ;
}

int main(void)
{
	int i, pr, t ;
	long long min = 0 ;

	scanf("%d%d",&n,&k) ;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&pr,&t) ;
		sum += pr ;
		if(t==1)
		{
			stool[cnt++] = pr ;
			sid[cnt-1] = i+1 ;
		}
		else
		{
			pen[p++] = pr ;
			pid[p-1] = i+1 ;
		}
	}

	qsort(stool,cnt,sizeof(stool[0]),cmp) ;
	qsort(pen,p,sizeof(pen[0]),cmp) ;

	d = k > cnt ? cnt : k ;

	for(i=0;i<d;i++)
	{
		L[i] = stool[cnt-i-1] ;
	}
	L[d-1] = stool[0] ;

	if(cnt>=k&&pen[0]<L[d-1]&&p>0)
	{
		L[d-1] = pen[0] ;
	}

	for(i=0;i<d;i++)
	{
		min += L[i] ;
	}

	printf("%I64d.%d\n",sum-(min/2)-(min%2),min%2==1?5:0) ;
	for(i=0;i<d-1;i++)
	{
		printf("1 %d\n",sid[cnt-i-1]) ;
	}
	if(cnt>=k)
	{
		printf("%d",n-(d-1)) ;
		for(;i<cnt;i++)
		{
			printf(" %d",sid[cnt-i-1]) ;
		}
		for(i=0;i<p;i++)
		{
			printf(" %d",pid[i]) ;
		}
		printf("\n") ;
	}
	else
	{
		if(cnt>0)
		{
			printf("1 %d\n",sid[0]) ; i++ ;
		}
		for(;i<k-1;i++)
		{
			printf("1 %d\n",pid[--p]) ;
		}
		printf("%d",p) ;
		while(p)
		{
			printf(" %d",pid[--p]) ;
		}
		printf("\n") ;
	}

	return 0 ;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>

int k, n ;
int cnt = 0 ;
int p = 0 ;
int stool[1100] ;
int sid[1100] ;
int pen[1100] ;
int pid[1100] ;
int L[1100] ;
int d ;
long long sum = 0 ;

int cmp(const void *a, const void *b)
{
	return *((int *)a) > *((int *)b) ? 1 : -1 ;
}

int main(void)
{
	int i, pr, t ;
	long long min = 0 ;

	scanf("%d%d",&n,&k) ;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&pr,&t) ;
		sum += pr ;
		if(t==1)
		{
			stool[cnt++] = pr ;
			sid[cnt-1] = i+1 ;
		}
		else
		{
			pen[p++] = pr ;
			pid[p-1] = i+1 ;
		}
	}

	qsort(stool,cnt,sizeof(stool[0]),cmp) ;
	qsort(pen,p,sizeof(pen[0]),cmp) ;

	d = k > cnt ? cnt : k ;

	for(i=0;i<d;i++)
	{
		L[i] = stool[cnt-i-1] ;
	}
	L[d-1] = stool[0] ;

	if(cnt>=k&&pen[0]<L[d-1])
	{
		L[d-1] = pen[0] ;
	}

	for(i=0;i<d;i++)
	{
		min += L[i] ;
	}

	printf("%I64d.%d\n",sum-(min/2)-(min%2),min%2==1?5:0) ;
	for(i=0;i<d-1;i++)
	{
		printf("1 %d\n",sid[cnt-i-1]) ;
	}
	if(cnt>=k)
	{
		printf("%d",n-(d-1)) ;
		for(;i<cnt;i++)
		{
			printf(" %d",sid[cnt-i-1]) ;
		}
		for(i=0;i<p;i++)
		{
			printf(" %d",pid[i]) ;
		}
		printf("\n") ;
	}
	else
	{
		printf("1 %d\n",sid[0]) ;
		for(i++;i<k-1;i++)
		{
			printf("1 %d\n",pid[--p]) ;
		}
		printf("%d",p) ;
		while(p)
		{
			printf(" %d",pid[--p]) ;
		}
		printf("\n") ;
	}

	return 0 ;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>

int k, n ;
int cnt = 0 ;
int p = 0 ;
int stool[1100][2] ;
int pen[1100][2] ;
int L[1100] ;
int d ;
long long sum = 0 ;

int cmp(const void *a, const void *b)
{
	return ((int *)a)[0] > ((int *)b)[0] ? 1 : -1 ;
}

int main(void)
{
	int i, pr, t ;
	long long min = 0 ;

	scanf("%d%d",&n,&k) ;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&pr,&t) ;
		sum += pr ;
		if(t==1)
		{
			stool[cnt++][0] = pr ;
			stool[cnt-1][1] = i+1 ;
		}
		else
		{
			pen[p++][0] = pr ;
			pen[p-1][1] = i+1 ;
		}
	}

	qsort(stool,cnt,sizeof(stool[0]),cmp) ;
	qsort(pen,p,sizeof(pen[0]),cmp) ;

	d = k > cnt ? cnt : k ;

	for(i=0;i<d;i++)
	{
		L[i] = stool[cnt-i-1][0] ;
	}
	L[d-1] = stool[0][0] ;

	if(cnt>=k&&pen[0][0]<L[d-1]&&p>0)
	{
		L[d-1] = pen[0][0] ;
	}

	for(i=0;i<d;i++)
	{
		min += L[i] ;
	}

	printf("%I64d.%d\n",sum-(min/2)-(min%2),min%2==1?5:0) ;
	for(i=0;i<d-1;i++)
	{
		printf("1 %d\n",stool[cnt-i-1][1]) ;
	}
	if(cnt>=k)
	{
		printf("%d",n-(d-1)) ;
		for(;i<cnt;i++)
		{
			printf(" %d",stool[cnt-i-1][1]) ;
		}
		for(i=0;i<p;i++)
		{
			printf(" %d",pen[i][1]) ;
		}
		printf("\n") ;
	}
	else
	{
		if(cnt>0)
		{
			printf("1 %d\n",stool[0][1]) ; i++ ;
		}
		for(;i<k-1;i++)
		{
			printf("1 %d\n",pen[--p][1]) ;
		}
		printf("%d",p) ;
		while(p)
		{
			printf(" %d",pen[--p][1]) ;
		}
		printf("\n") ;
	}

	return 0 ;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>

int k, n ;
int cnt = 0 ;
int p = 0 ;
int stool[1100] ;
int sid[1100] ;
int pen[1100] ;
int pid[1100] ;
int L[1100] ;
int d ;
long long sum = 0 ;

int cmp(const void *a, const void *b)
{
	return *((int *)a) > *((int *)b) ? 1 : -1 ;
}

int main(void)
{
	int i, pr, t ;
	long long min = 0 ;

	scanf("%d%d",&n,&k) ;
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&pr,&t) ;
		sum += pr ;
		if(t==1)
		{
			stool[cnt++] = pr ;
			sid[cnt-1] = i+1 ;
		}
		else
		{
			pen[p++] = pr ;
			pid[p-1] = i+1 ;
		}
	}

	qsort(stool,cnt,sizeof(stool[0]),cmp) ;
	qsort(pen,p,sizeof(pen[0]),cmp) ;

	d = k > cnt ? cnt : k ;

	for(i=0;i<d;i++)
	{
		L[i] = stool[cnt-i-1] ;
	}
	L[d-1] = stool[0] ;

	if(cnt>=k&&pen[0]<L[d-1])
	{
		L[d-1] = pen[0] ;
	}

	for(i=0;i<d;i++)
	{
		min += L[i] ;
	}

	printf("%I64d.%d\n",sum-(min/2)-(min%2),min%2==1?5:0) ;
	for(i=0;i<d-1;i++)
	{
		printf("1 %d\n",sid[cnt-i-1]) ;
	}
	if(cnt>=k)
	{
		printf("%d",n-(d-1)) ;
		for(;i<cnt;i++)
		{
			printf(" %d",sid[cnt-i-1]) ;
		}
		for(i=0;i<p;i++)
		{
			printf(" %d",pid[i]) ;
		}
		printf("\n") ;
	}
	else
	{
		if(cnt>0)
		{
			printf("1 %d\n",sid[0]) ;
		}
		for(i++;i<k-1;i++)
		{
			printf("1 %d\n",pid[--p]) ;
		}
		printf("%d",p) ;
		while(p)
		{
			printf(" %d",pid[--p]) ;
		}
		printf("\n") ;
	}

	return 0 ;
}


#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <ctime>
#include <iostream>
#include <utility>
#include <algorithm>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <complex>

#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fs first
#define sc second
#define sz(x) (int((x).size()))
#define all(x) ((x).begin()),((x).end())
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define fab(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define fba(i,b,a) for(int (i)=(b);(i)>=(a);(i)--)
#define MAX(a,x) a=max(a,x)
#define MIN(a,x) a=min(a,x)

using namespace std;

const double eps = 1e-10, inf = 1e10;
typedef long long ll;

int n, k, type[1010];
vector<int> carr[1010];
vector< pair<int,int> > stool, pencil, input;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif

    scanf("%d%d", &n, &k);
    rep(i, n)
    {
        int c, t;
        scanf("%d%d", &c, &t);
        ((t == 1) ? stool : pencil).pb(mp(c, i));
        input.pb(mp(c, i));
        type[i] = t;
    }

    sort(stool.rbegin(), stool.rend());
    sort(pencil.rbegin(), pencil.rend());

    ll ans = 0;
    int i = 0, j = 0, lasthas = 0, minAss = numeric_limits<int>::max();
    while (i < k-1 && i < sz(stool)) ans += stool[i].fs, carr[i].pb(stool[i].sc), i++;
    while (i+j < k-1 && j < sz(pencil)) ans += 2*pencil[j].fs, carr[i+j].pb(pencil[j].sc), j++;
    while (i < sz(stool)) MIN(minAss, stool[i].fs), ans += 2*stool[i].fs, carr[k-1].pb(stool[i].sc), i++, lasthas = 1;
    while (j < sz(pencil)) MIN(minAss, pencil[j].fs), ans += 2*pencil[j].fs, carr[k-1].pb(pencil[j].sc), j++;
    if (lasthas) ans -= minAss;

    cout << (ans/2) << '.' << (ans%2*5) << '\n';
    rep(i, k)
    {
        printf("%d", sz(carr[i]));
        rep(j, sz(carr[i])) printf(" %d", carr[i][j]+1);
        printf("\n");
    }
    return 0;
}


#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <ctime>
#include <iostream>
#include <utility>
#include <algorithm>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <complex>

#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fs first
#define sc second
#define sz(x) (int((x).size()))
#define all(x) ((x).begin()),((x).end())
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define fab(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define fba(i,b,a) for(int (i)=(b);(i)>=(a);(i)--)
#define MAX(a,x) a=max(a,x)
#define MIN(a,x) a=min(a,x)

using namespace std;

const double eps = 1e-10, inf = 1e10;
typedef long long ll;

int n, k, type[1010];
vector<int> carr[1010];
vector< pair<int,int> > stool, pencil, input;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif

    scanf("%d%d", &n, &k);
    rep(i, n)
    {
        int c, t;
        scanf("%d%d", &c, &t);
        ((t == 1) ? stool : pencil).pb(mp(c, i));
        input.pb(mp(c, i));
        type[i] = t;
    }

    sort(stool.rbegin(), stool.rend());
    sort(pencil.rbegin(), pencil.rend());
    int i;
    for (i=0; i<k-1 && i<sz(stool); i++) carr[i].pb(stool[i].sc);
    while (i<sz(stool)) carr[k-1].pb(stool[i++].sc);

    for (i=0; i<k-1 && i<sz(pencil); i++) if (carr[i].empty() || pencil[i].fs >= input[carr[i][0]].fs)
    {
        carr[i].pb(pencil[i].sc);
    }
    else carr[k-1].pb(pencil[i].sc);
    while (i<sz(pencil)) carr[k-1].pb(pencil[i++].sc);

    rep(i, k)
    {
        if (carr[i].empty())
        {
            fba(j, i-1, 0) if (sz(carr[j]) > 1 && type[carr[j].back()] == 2)
            {
                carr[i].pb(carr[j].back());
                carr[j].pop_back();
                break;
            }
        }
    }

    double ans = 0;
    rep(i, k)
    {
        if (type[carr[i][0]] == 1)
        {
            ans += input[carr[i][0]].fs / 2.0;
        }
        else
        {
            ans += input[carr[i][0]].fs;
        }

        fab(j, 1, sz(carr[i])-1)
            ans += input[carr[i][j]].fs;
    }

    cout.precision(1);
    cout << fixed << ans << '\n';
    rep(i, k)
    {
        printf("%d", sz(carr[i]));
        rep(j, sz(carr[i])) printf(" %d", carr[i][j]+1);
        printf("\n");
    }

    return 0;
}


#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <ctime>
#include <iostream>
#include <utility>
#include <algorithm>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <complex>

#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fs first
#define sc second
#define sz(x) (int((x).size()))
#define all(x) ((x).begin()),((x).end())
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define fab(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define fba(i,b,a) for(int (i)=(b);(i)>=(a);(i)--)
#define MAX(a,x) a=max(a,x)
#define MIN(a,x) a=min(a,x)

using namespace std;

const double eps = 1e-10, inf = 1e10;
typedef long long ll;

int n, k, type[1010];
vector<int> carr[1010];
vector< pair<int,int> > stool, pencil, input;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif

    scanf("%d%d", &n, &k);
    rep(i, n)
    {
        int c, t;
        scanf("%d%d", &c, &t);
        ((t == 1) ? stool : pencil).pb(mp(c, i));
        input.pb(mp(c, i));
        type[i] = t;
    }

    sort(stool.rbegin(), stool.rend());
    sort(pencil.rbegin(), pencil.rend());
    int i;
    for (i=0; i<k-1 && i<sz(stool); i++) carr[i].pb(stool[i].sc);
    while (i<sz(stool)) carr[k-1].pb(stool[i++].sc);

    for (i=0; i<k-1 && i<sz(pencil); i++) if (carr[i].empty() || pencil[i].fs >= input[carr[i][0]].fs)
    {
        carr[i].pb(pencil[i].sc);
    }
    else carr[k-1].pb(pencil[i].sc);
    while (i<sz(pencil)) carr[k-1].pb(pencil[i++].sc);

    rep(i, k)
    {
        if (carr[i].empty())
        {
            fba(j, i-1, 0) if (sz(carr[j]) > 1 && type[carr[j].back()])
            {
                carr[i].pb(carr[j].back());
                carr[j].pop_back();
                break;
            }
        }
    }

    double ans = 0;
    rep(i, k)
    {
        if (type[carr[i][0]] == 1)
        {
            ans += input[carr[i][0]].fs / 2.0;
        }
        else
        {
            ans += input[carr[i][0]].fs;
        }

        fab(j, 1, sz(carr[i])-1)
            ans += input[carr[i][j]].fs;
    }

    cout.precision(1);
    cout << fixed << ans << '\n';
    rep(i, k)
    {
        printf("%d", sz(carr[i]));
        rep(j, sz(carr[i])) printf(" %d", carr[i][j]+1);
        printf("\n");
    }

    return 0;
}


#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <cassert>
#include <ctime>
#include <iostream>
#include <utility>
#include <algorithm>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <complex>

#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fs first
#define sc second
#define sz(x) (int((x).size()))
#define all(x) ((x).begin()),((x).end())
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define fab(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define fba(i,b,a) for(int (i)=(b);(i)>=(a);(i)--)
#define MAX(a,x) a=max(a,x)
#define MIN(a,x) a=min(a,x)

using namespace std;

const double eps = 1e-10, inf = 1e10;
typedef long long ll;

int n, k, type[1010];
vector<int> carr[1010];
vector< pair<int,int> > stool, pencil, input;

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif

    scanf("%d%d", &n, &k);
    rep(i, n)
    {
        int c, t;
        scanf("%d%d", &c, &t);
        ((t == 1) ? stool : pencil).pb(mp(c, i));
        input.pb(mp(c, i));
        type[i] = t;
    }

    sort(stool.rbegin(), stool.rend());
    sort(pencil.rbegin(), pencil.rend());
    int i;
    for (i=0; i<k-1 && i<sz(stool); i++) carr[i].pb(stool[i].sc);
    while (i<sz(stool)) carr[k-1].pb(stool[i++].sc);

    for (i=0; i<k-1 && i<sz(pencil); i++) if (carr[i].empty() || pencil[i].fs >= input[carr[i][0]].fs)
    {
        carr[i].pb(pencil[i].sc);
    }
    else carr[k-1].pb(pencil[i].sc);
    while (i<sz(pencil)) carr[k-1].pb(pencil[i++].sc);

    rep(i, k)
    {
        if (carr[i].empty())
        {
            fba(j, i-1, 0) if (sz(carr[j]) > 1 && type[carr[j].back()] == 2)
            {
                carr[i].pb(carr[j].back());
                carr[j].pop_back();
                break;
            }
        }
    }

    double ans = 0;
    rep(i, k-1)
    {
        if (type[carr[i][0]] == 1)
        {
            ans -= input[carr[i][0]].fs / 2.0;
        }

        fab(j, 0, sz(carr[i])-1)
            ans += input[carr[i][j]].fs;
    }

    rep(i, sz(carr[k-1])) ans += input[carr[k-1][i]].fs;

    int min_ass = numeric_limits<int>::max(), has = 0, possible = 0;
    rep(j, sz(carr[k-1]))
    {
        if (type[carr[k-1][j]] == 1) possible = 1;
        if (min_ass > input[carr[k-1][j]].fs)
        {
            if (type[carr[k-1][j]] == 1)
            {
                has = 1;
            }
            min_ass = input[carr[k-1][j]].fs;
        }
        else if (min_ass == input[carr[k-1][j]].fs && !has)
        {
            if (type[carr[k-1][j]] == 1)
            {
                has = 1;
            }
            min_ass = input[carr[k-1][j]].fs;
        }
    }
    if (possible)
    {
        if (has) ans -= min_ass / 2.0;
        else ans -= min_ass;
    }
    cout.precision(1);
    cout << fixed << ans << '\n';
    rep(i, k)
    {
        printf("%d", sz(carr[i]));
        rep(j, sz(carr[i])) printf(" %d", carr[i][j]+1);
        printf("\n");
    }

    return 0;
}