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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-5;
const int N = 2e5 + 10;

void redirect() {
    #ifdef LOCAL
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
}

ll n, k;
ll a[N], cnt[N];
ll lmt[N], suf[N];
vector<int> G[N]; ll acc[N];

int main() {
    redirect();

    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> k;
    for (int i=1; i<=n; i++) {
        cin >> a[i]; cnt[a[i]]++;
    }

    for (int i=1; i<=k; i++) {
        cin >> lmt[i];
    }

    for (int i=k; i>=1; i--) {
        suf[i] = suf[i+1] + cnt[i];
    }

    ll l = 1, r = 2e5;
    while (l<r) {
        ll mid = (l+r) >> 1;
        bool f = true;
        for (int i=k; i>=1; i--) {
            if ( suf[i] > lmt[i]*mid ) {
                f = false;
                break;
            }
        }

        if (f) r = mid;
        else l = mid+1;
    }

    for (int i=k; i>=1; i--) {

        for (int j=1; j<=l; j++) {

            while ( acc[j] < lmt[i] && cnt[i] > 0 ) {
                G[j].push_back(i);
                acc[j] ++;
                cnt[i] --;
            }

        }

    }

    cout << l << endl;
    for (int i=1; i<=l; i++) {
        cout << G[i].size() << ' ';
        for (auto x:G[i]) cout << x << ' ';
        cout << "\n";
    }

    return 0;
}

/*
-----------------
author:dragon_bra
-----------------
*/


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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-5;
const int N = 2e5 + 10;

void redirect() {
    #ifdef LOCAL
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
}

ll n, k;
int a[N], cnt[N];
ll lmt[N], suf[N];
vector<int> G[N]; ll acc[N];

int main() {
    redirect();

    ios::sync_with_stdio(false);
    cin.tie(0);

    scanf("%lld%lld",&n,&k);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]); cnt[a[i]]++;
    }

    for (int i=1; i<=k; i++) {
        scanf("%lld",&lmt[i]);
    }

    for (int i=k; i>=1; i--) {
        suf[i] = suf[i+1] + cnt[i];
    }

    ll l = 1, r = 3e5;
    while (l<r) {
        ll mid = (l+r) >> 1;
        bool f = true;
        for (int i=k; i>=1; i--) {
            if ( suf[i] > lmt[i]*mid ) {
                f = false;
                break;
            }
        }

        if (f) r = mid;
        else l = mid+1;
    }

    for (int i=k; i>=1; i--) {

        for (int j=1; j<=l; j++) {

            while ( acc[j] < lmt[i] && cnt[i] > 0 ) {
                G[j].push_back(i);
                acc[j] ++;
                cnt[i] --;
            }

        }

    }

    printf("%lld\n",l);
    for (int i=1; i<=l; i++) {
        printf("%d ",G[i].size());
        for (auto x:G[i]) printf("%d ",x);
        printf("\n");
    }

    return 0;
}

/*
-----------------
author:dragon_bra
-----------------
*/


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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-5;
const int N = 2e5 + 10;

void redirect() {
    #ifdef LOCAL
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
}

ll n, k;
int a[N], cnt[N];
ll lmt[N], suf[N];
vector<int> G[N]; ll acc[N];

bool vis[N]; int pt[N];

int main() {
    redirect();

    //ios::sync_with_stdio(false);
    //cin.tie(0);

    scanf("%lld%lld",&n,&k);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]); cnt[a[i]]++;
    }

    for (int i=1; i<=k; i++) {
        scanf("%lld",&lmt[i]);
    }

    int mk = 0;
    for (int i=1; i<=k; i++) {
        pt[i] = mk;
        if (i < k && lmt[i] > lmt[i+1]) mk = i;
    }

    for (int i=k; i>=1; i--) {
        suf[i] = suf[i+1] + cnt[i];
    }

    ll l = 1, r = 3e5;
    while (l<r) {
        ll mid = (l+r) >> 1;
        bool f = true;
        for (int i=k; i>=1; i--) {
            if ( suf[i] > lmt[i]*mid ) {
                f = false;
                break;
            }
        }

        if (f) r = mid;
        else l = mid+1;
    }

    int now = k;
    int j = 0;
    for (int i=k; i>=1; i--) {
        while ( cnt[i] > 0 ) {
            G[j%l+1].push_back(i);
            j++;
            cnt[i] --;
        }
    }

    printf("%lld\n",l);
    for (int i=1; i<=l; i++) {
        printf("%d ",G[i].size());
        for (auto x:G[i]) printf("%d ",x);
        printf("\n");
    }

    return 0;
}

/*
-----------------
author:dragon_bra
-----------------
*/


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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-5;
const int N = 2e5 + 10;

void redirect() {
    #ifdef LOCAL
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
}

ll n, k;
int a[N], cnt[N];
ll lmt[N], suf[N];
vector<int> G[N]; ll acc[N];

bool vis[N]; int pt[N];

int main() {
    redirect();

    //ios::sync_with_stdio(false);
    //cin.tie(0);

    scanf("%lld%lld",&n,&k);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]); cnt[a[i]]++;
    }

    for (int i=1; i<=k; i++) {
        scanf("%lld",&lmt[i]);
    }

    int mk;
    for (int i=1; i<=k; i++) {
        pt[i] = mk;
        if (i < k && lmt[i] > lmt[i+1]) mk = i;
    }

    for (int i=k; i>=1; i--) {
        suf[i] = suf[i+1] + cnt[i];
    }

    ll l = 1, r = 3e5;
    while (l<r) {
        ll mid = (l+r) >> 1;
        bool f = true;
        for (int i=k; i>=1; i--) {
            if ( suf[i] > lmt[i]*mid ) {
                f = false;
                break;
            }
        }

        if (f) r = mid;
        else l = mid+1;
    }

    int now = k;
    for (int j=1; j<=l; j++) {
        while (cnt[now]==0&&now>=1) now--;
        for (int i=now; i>=1;) {
            while ( acc[j] < lmt[i] && cnt[i] > 0 ) {
                G[j].push_back(i);
                acc[j] ++;
                cnt[i] --;
            }
            if (acc[j] >= lmt[i]) i = pt[i];
            else {i--;}
        }
    }

    printf("%lld\n",l);
    for (int i=1; i<=l; i++) {
        printf("%d ",G[i].size());
        for (auto x:G[i]) printf("%d ",x);
        printf("\n");
    }

    return 0;
}

/*
-----------------
author:dragon_bra
-----------------
*/


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

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-5;
const int N = 2e5 + 10;

void redirect() {
    #ifdef LOCAL
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
}

ll n, k;
int a[N], cnt[N];
ll lmt[N], suf[N];
vector<int> G[N]; ll acc[N];

bool vis[N]; int pt[N];

int main() {
    redirect();

    //ios::sync_with_stdio(false);
    //cin.tie(0);

    scanf("%lld%lld",&n,&k);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]); cnt[a[i]]++;
    }

    for (int i=1; i<=k; i++) {
        scanf("%lld",&lmt[i]);
    }

    int mk = 0;
    for (int i=1; i<=k; i++) {
        pt[i] = mk;
        if (i < k && lmt[i] > lmt[i+1]) mk = i;
    }

    for (int i=k; i>=1; i--) {
        suf[i] = suf[i+1] + cnt[i];
    }

    ll l = 1, r = 3e5;
    while (l<r) {
        ll mid = (l+r) >> 1;
        bool f = true;
        for (int i=k; i>=1; i--) {
            if ( suf[i] > lmt[i]*mid ) {
                f = false;
                break;
            }
        }

        if (f) r = mid;
        else l = mid+1;
    }

    int now = k;
    for (int j=1; j<=l; j++) {
        while (cnt[now]==0&&now>=1) now--;
        for (int i=now; i>=1;) {
            while ( acc[j] < lmt[i] && cnt[i] > 0 ) {
                G[j].push_back(i);
                acc[j] ++;
                cnt[i] --;
            }
            if (acc[j] >= lmt[i]) i = pt[i];
            else {i--;}
        }
    }

    printf("%lld\n",l);
    for (int i=1; i<=l; i++) {
        printf("%d ",G[i].size());
        for (auto x:G[i]) printf("%d ",x);
        printf("\n");
    }

    return 0;
}

/*
-----------------
author:dragon_bra
-----------------
*/


#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

inline bool jay(int mid)
{
	for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false;
	return true;
}

int main(){
	scanf("%d%d",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%d",&c[i]);
	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];

	int l,r,mid;
	l=0; r=n;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%d\n",ans);
	int i=n,j=1;
	while (i>=1)
	{
		vec[j].push_back(a[i]),i--,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%d ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%d ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

int main(){
	scanf("%d%d",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%d",&c[i]);
	for (register int i=1; i<=k; ++i)
	{
		ans=max(ans,now/c[i]);
		now-=sum[i];
	}
	printf("%d\n",ans);
	sort(a+1,a+n+1);
	l[++tot]=1;
	for (register int i=2; i<=n; ++i) if (a[i]!=a[i-1]) r[tot]=i-1,l[++tot]=i;
	r[tot]=n;
//	memset(sum,0,sizeof(sum));
//	for (register int i=1; i<=n; ++i) sum[a[i]]++;
//	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];
//	for (register int i=1; i<=tot; ++i) printf("%d %d\n",l[i],r[i]);
/*	for (register int i=1; i<=tot; ++i)
	{
		int j=1,hh=c[i];
		printf("c[i]=%d\n",c[i]);
		for (register int k=l[i]; k<=r[i]; ++k)
		{
			vec[j].push_back(a[k]),hh--;
			if (!hh) j++,hh=c[i];
		}
	}*/
	reverse(a+1,a+n+1);
	int i=1,j=1;
	while (i<=n)
	{
		vec[j].push_back(a[i]),i++,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%d ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%d ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

inline bool jay(int mid)
{
	for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false;
	return true;
}

signed main(){
	scanf("%lld%lld",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%lld",&c[i]);
	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];

	int l,r,mid;
	l=0; r=n;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	sort(a+1,a+n+1);
	int i=1,j=1;
	while (i<=n)
	{
		vec[j].push_back(a[i]),i++,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%lld ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%lld ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

int main(){
	scanf("%d%d",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%d",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%d",&c[i]);
	for (register int i=1; i<=k; ++i)
	{
		ans=max(ans,now/c[i]);
		now-=sum[i];
	}
	printf("%d\n",ans);
	sort(a+1,a+n+1);
	l[++tot]=1;
	for (register int i=2; i<=n; ++i) if (a[i]!=a[i-1]) r[tot]=i-1,l[++tot]=i;
	r[tot]=n;
	reverse(a+1,a+n+1);
	int i=n,j=1;
	while (i>=1)
	{
		vec[j].push_back(a[i]),i--,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%d ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%d ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

inline bool jay(int mid)
{
	for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false;
	return true;
}

signed main(){
	scanf("%lld%lld",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%lld",&c[i]);
	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];

	int l,r,mid;
	l=0; r=n;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	int i=n,j=1;
	while (i>=1)
	{
		vec[j].push_back(a[i]),i--,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%lld ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%lld ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

inline bool jay(int mid)
{
	for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false;
	return true;
}

signed main(){
	scanf("%lld%lld",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%lld",&c[i]);
	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];
	for (register int i=1; i<=k; ++i) ans=max(ans,sum[i]/c[i]);

/*	int l,r,mid;
	l=0; r=n;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}*/
	printf("%lld\n",ans);
	sort(a+1,a+n+1);
	int i=1,j=1;
	while (i<=n)
	{
		vec[j].push_back(a[i]),i++,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%lld ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%lld ",vec[i][j]);
		puts("");
	}
return 0;
}


#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int T;
int n,k,now,ans,tot;
int sum[N],c[N],a[N],l[N],r[N];
vector<int>vec[N];

inline bool jay(int mid)
{
	for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false;
	return true;
}

signed main(){
	scanf("%lld%lld",&n,&k);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]),sum[a[i]]++;
	now=n;
	for (register int i=1; i<=k; ++i) scanf("%lld",&c[i]);
	for (register int i=k; i>=1; --i) sum[i]+=sum[i+1];
	for (register int i=1; i<=k; ++i) ans=max(ans,sum[i]/c[i]+(sum[i]%c[i]!=0));

/*	int l,r,mid;
	l=0; r=n;
	while (l<=r)
	{
		mid=l+r>>1;
		if (jay(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}*/
	printf("%lld\n",ans);
	sort(a+1,a+n+1);
	int i=1,j=1;
	while (i<=n)
	{
		vec[j].push_back(a[i]),i++,j++;
		if (j==ans+1) j=1;
	}
	for (register int i=1; i<=ans; ++i)
	{
		printf("%lld ",vec[i].size());
		for (register int j=0; j<vec[i].size(); ++j) printf("%lld ",vec[i][j]);
		puts("");
	}
return 0;
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}

	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			mymove.push_back(i);
		}
	}
	int movelen=mymove.size();
	int cou=0,maxi=k;
	while(1)
	{
		int nowsize=0,least=0;
		bool fl=0;
		for(int movei=least;movei<movelen;++movei)
		{
			int i=mymove[movei];
			while(tong[i]>0&&nowsize<c[i])
			{
				if(fl==0)
				{
					fl=1;
					least=movei;
				}
				ans[cou].push_back(i);
				++nowsize;
				--tong[i];
			}
		}
		if(fl==0)break;
		++cou;
	}
	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	sort(m+1,m+1+n);
	for(int i=n;i>=1;--i)
	{
		if(m[i]!=m[i+1])
		{
			startat[m[i]]=i;
		}
	}
	int cou=0;
	while(1)
	{
		for(int i=k;i>=1;--i)
		{
			for(int j=startat[i];m[j]==i&&ans[cou].size()<c[i];j--)
			{
				ans[cou].push_back(m[j]);
				--startat[i];
			}
		}
		if(ans[cou].size()==0)break;
		++cou;
	}
	cout<<cou<<endl;
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 20, sizeof(char)), _IOFBF, 1 << 20);
    setvbuf(stdout, (char *) calloc(1 << 20, sizeof(char)), _IOFBF, 1 << 20);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}

	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			mymove.push_back(i);
		}
	}
	int movelen=mymove.size();
	int cou=0,maxi=k;
	while(1)
	{
		int nowsize=0,least=0;
		bool fl=0;
		for(int movei=least;movei<movelen;++movei)
		{
			int i=mymove[movei];
			while(tong[i]>0&&nowsize<c[i])
			{
				if(fl==0)
				{
					fl=1;
					least=movei;
				}
				ans[cou].push_back(i);
				++nowsize;
				--tong[i];
			}
		}
		if(fl==0)break;
		++cou;
	}
	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
vector<int> mymove;
int main()
{
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	sort(m+1,m+1+n);
	for(int i=n;i>=1;--i)
	{
		if(m[i]!=m[i+1])
		{
			startat[m[i]]=i;
			mymove.push_back(m[i]);
		}
	}
	int movelen=mymove.size();
	int cou=0,maxi=k;
	while(1)
	{
		int nowsize=0,least=0;
		bool fl=0;
		for(int movei=least;movei<movelen;++movei)
		{
			int i=mymove[movei];
			for(int j=startat[i];m[j]==i&&nowsize<c[i];j--)
			{
				if(fl==0)
				{
					fl=1;
					least=movei;
				}
				ans[cou].push_back(m[j]);
				++nowsize;
				--startat[i];
			}
		}
		if(fl==0)break;
		++cou;
	}
	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int prex[N],postx[N];
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
    setvbuf(stdout, (char *) calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	int lasttong=0;
	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			prex[i]=lasttong;
			postx[lasttong]=i;
			lasttong=i;
			mymove.push_back(i);
		}
	}
	postx[lasttong]=-1;
	int movelen=mymove.size();
	int cou=0,maxi=k;

		for(int i=postx[0];i!=-1;i=postx[i])
		{
			int j=0;
			while(tong[i]>0)
			{
				if(ans[j].size()<c[i])
				{
					ans[j].push_back(i);
					--tong[i];
				}
				else
					++j;
			}
			if(j>=cou)cou=j+1;
		}

	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int prex[N],postx[N];
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
    setvbuf(stdout, (char *) calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	int lasttong=0;
	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			prex[i]=lasttong;
			postx[lasttong]=i;
			lasttong=i;
			mymove.push_back(i);
		}
	}
	postx[lasttong]=-1;
	int movelen=mymove.size();
	int cou=0,maxi=k;

		for(int i=postx[0];i!=-1;i=postx[i])
		{
			int j=0;
			while(tong[i]>0)
			{
				if(ans[j].size()<c[i])
				{
					ans[j].push_back(i);
					--tong[i];
				}
				else
					++j;
			}
			if(j>cou)cou=j+1;
		}

	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
    setvbuf(stdout, (char *) calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}

	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			mymove.push_back(i);
		}
	}
	int movelen=mymove.size();
	int cou=0,maxi=k;
	while(1)
	{
		int nowsize=0,least=0;
		bool fl=0;
		for(int movei=least;movei<movelen;++movei)
		{
			int i=mymove[movei];
			while(tong[i]>0&&nowsize<c[i])
			{
				if(fl==0)
				{
					fl=1;
					least=movei;
				}
				ans[cou].push_back(i);
				++nowsize;
				--tong[i];
			}
		}
		if(fl==0)break;
		++cou;
	}
	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int prex[N],postx[N];
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
    setvbuf(stdout, (char *) calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	int lasttong=0;
	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			prex[i]=lasttong;
			postx[lasttong]=i;
			lasttong=i;
			mymove.push_back(i);
		}
	}
	postx[lasttong]=-1;
	int movelen=mymove.size();
	int cou=0,maxi=k;
	while(1)
	{
		int nowsize=0;
//		bool fl=0;
		for(int i=postx[0];i!=-1;i=postx[i])
		{
//			cout<<i<<endl;
			while(tong[i]>0&&nowsize<c[i])
			{
				ans[cou].push_back(i);
				++nowsize;
				--tong[i];
			}
			if(tong[i]<=0)
			{
//				int pret=prex[i];
				postx[prex[i]]=postx[i];
				if(postx[i]!=-1)
					prex[postx[i]]=prex[i];
			}
		}
		if(ans[cou].size()==0)break;
		++cou;
	}
	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
#define N 201000
int m[N],c[N];
vector<int> ans[N];
int startat[N];
int tong[N];
vector<int> mymove;
int prex[N],postx[N];
int main()
{
	setvbuf(stdin, (char *)calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
    setvbuf(stdout, (char *) calloc(1 << 31, sizeof(char)), _IOFBF, 1 << 31);
	int n,k;
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&m[i]);
		++tong[m[i]];
	}
	for(int i=1;i<=k;++i)
	{
		scanf("%d",&c[i]);
	}
	int lasttong=0;
	for(int i=k;i>=1;--i)
	{
		if(tong[i])
		{
			prex[i]=lasttong;
			postx[lasttong]=i;
			lasttong=i;
			mymove.push_back(i);
		}
	}
	postx[lasttong]=-1;
	int movelen=mymove.size();
	int cou=0,maxi=k;
	int lastj=0;
		for(int i=postx[0];i!=-1;i=postx[i])
		{
			int j=0;
			if(i!=postx[0]&&c[i]==c[prex[i]])
			{
				j=lastj;
			}
			while(tong[i]>0)
			{
				if(ans[j].size()<c[i])
				{
					ans[j].push_back(i);
					--tong[i];
				}
				else
					++j;
			}
			lastj=j;
			if(j>=cou)cou=j+1;
		}

	printf("%d\n",cou);
	for(int i=0;i<cou;++i)
	{
		int alen=ans[i].size();
		printf("%d ",alen);
		for(int j=0;j<alen;++j)
		{
			printf("%d ",ans[i][j]);
		}
		printf("\n");
	}
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(ll i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot;
vector<int>vec[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;
    dec(i,m,1){
	inc(j,1,tot){
	    while(a[i]&&c[i]>vec[j].size())vec[j].push_back(i),a[i]--;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>vec[tot].size())vec[tot].push_back(i),a[i]--;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%lu ",vec[i].size());
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(ll i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;
    dec(i,m,1){
	inc(j,1,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(ll i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]<c[i+1])cnt=1;
	inc(j,cnt,tot){
	    cnt=j;
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(ll i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]<c[i+1])cnt=1;
	inc(j,cnt,tot){
	    cnt=j;
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    cnt=tot;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]>c[i+1])cnt=1;
	inc(j,cnt,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(c[i]>b[j])cnt=j;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	    if(c[i]>b[tot])cnt=tot;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]<c[i+1])cnt=1;
	inc(j,cnt,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(c[i]>b[j])cnt=j;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	    if(c[i]>b[tot])cnt=tot;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]<c[i+1])cnt=1;
	inc(j,cnt,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(c[i]>b[j])cnt=j;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	    if(c[i]>b[tot])cnt=j+1;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]>c[i+1])cnt=1;
	inc(j,cnt,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    cnt=j;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    cnt=tot;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


/**
 *　　　　　　  　　┏┓　　 　┏┓
 * 　　　　　  　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃　　　━　　 　┃
 * 　　　　　  　　┃　＞　　　＜　┃
 * 　　　　　  　　┃　　　　　　　┃
 * 　　　　　  　　┃...　⌒　... 　┃
 * 　　　　　　  　┃              ┃
 * 　　　　　　  　┗━┓          ┏━┛
 * 　　　　　　　　　┃          ┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃          ┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┃
 * 　　　　　　　　　┃          ┗━━━┓
 * 　　　　　　　　　┃              ┣┓
 * 　　　　　　　　　┃              ┏┛
 * 　　　　　　　　　┗┓┓┏━━━━━━━━┳┓┏┛
 * 　　　　　　　　　　┃┫┫       ┃┫┫
 * 　　　　　　　　　　┗┻┛       ┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<set>
#include<bitset>
#include<complex>
#include<assert.h>
#define inc(i,l,r) for(ll i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-8
#define succ(x) (1<<x)
#define mid (x+y>>1)
#define lowbit(x) (x&(-x))
#define sqr(x) (1ll*(x)*(x))
#define NM 200005
#define nm 200005
using namespace std;
const double pi=acos(-1);
const int inf=1e9+7;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

int n,m,a[NM],c[NM],tot,cnt;
vector<int>vec[NM];
int b[NM];

int main(){
    n=read();m=read();
    inc(i,1,n)a[read()]++;
    inc(i,1,m)c[i]=read();
    tot=0;cnt=1;
    c[m+1]=inf;
    dec(i,m,1){
	if(c[i]<c[i+1])cnt=1;
	inc(j,cnt,tot){
	    while(a[i]&&c[i]>b[j])vec[j].push_back(i),a[i]--,b[j]++;
	    if(!a[i])break;
	}
	while(a[i]){
	    tot++;
	    while(a[i]&&c[i]>b[tot])vec[tot].push_back(i),a[i]--,b[tot]++;
	}
    }
    printf("%d\n",tot);
    inc(i,1,tot){
	printf("%d ",b[i]);
	for(auto&j:vec[i])printf("%d ",j);putchar('\n');
    }
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,j,kiri,c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		j=kiri;
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			while(vec[kiri].size()>=c[1])
			{
				kiri++;
			}
			j++;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,j,c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		j=0;
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			j++;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,ii,j,kiri[200005],c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		j=kiri[i];
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			j++;
		}
		ii=i-1;
		while(c[ii]<=vec[j-1].size() && ii>0)
		{
			kiri[ii]=j-1;
			ii--;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,ii,j,kiri[200005],c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		j=kiri[i];
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			j++;
		}
		ii=i-1;
		while(c[ii]<=vec[j-1].size() && ii>0)
		{
			kiri[ii]=j;
			ii--;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,j,mem=1,sama[200005],kiri[200005],c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
		if(c[i]==c[mem])
		{
			sama[i]=mem;
		}
		else
		{
			mem=i;
		}
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		kiri[i]=kiri[sama[i]];
		j=kiri[i];
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			j++;
		}
		if(j>=2)
		{
			kiri[sama[i]]=j-2;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll ans,n,k,i,ii,j,kiri[200005],c[200005],banyak[200005];
int main()
{
	cin >> n >> k;
	ll m[n];
	for(i=0;i<n;i++)
	{
		cin >> m[i];
		banyak[m[i]]++;
	}
	for(i=1;i<=k;i++)
	{
		cin >> c[i];
	}
	vector<ll>vec[200005];
	for(i=k;i>=1;i--)
	{
		j=kiri[i];
		while(banyak[i]>0)
		{
			while(banyak[i]>0 && vec[j].size()<c[i])
			{
				banyak[i]--;
				vec[j].pb(i);
			}
			j++;
		}
		ii=i+1;;
		while(c[ii]<=vec[j].size())
		{
			kiri[ii]=j-1;
			ii++;
		}
		ans=max(j,ans);
	}
	cout << ans << endl;
	for(i=0;i<ans;i++)
	{
		cout << vec[i].size() << " ";
		for(j=0;j<vec[i].size();j++)
		{
			cout << vec[i][j] << " ";
		}
		cout << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++) cin>>c[i];
    int mx=0;
    for(int i=0;i<n;i++)
    {
        mx=max(mx,(n-i+c[a[i]-1]-1)/c[a[i]-1]);
    }
    return 0;
    cout<<mx<<endl;
    for(int i=0;i<mx;i++)
    {
        cout<<(n-1-i)/mx+1;
        for(int j=i;j<n;j+=mx) cout<<' '<<a[j];
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
int tp[maxn];
vector<int>ans[maxn];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) cin>>c[i];
    int mx=0;
    for(int i=1;i<=n;i++) tp[i]=c[1];
    int pre=0;
    for(int i=1;i<=n;i++)
    {
        while(!tp[pre+1]) ++pre;
        tp[pre+1]=min(tp[pre+1],c[a[i]]);
        tp[pre+1]--;
        ans[pre+1].push_back(a[i]);
        mx=max(mx,pre+1);
    }
    cout<<mx<<endl;
    for(int i=1;i<=mx;i++)
    {
        cout<<ans[i].size()<<' ';
        for(auto it:ans[i]) cout<<it<<' ';
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
vector<int>vec[maxn];
vector<int>tp[maxn];
int n,k;
bool chk(int x)
{
    for(int i=1;i<=x;i++)
    {
        tp[i].clear();
        for(int j=i;j<=n;j+=x)
            tp[i].push_back(a[j]);
        for(int j=tp[i].size()-1;j>=0;j--)
        {
            int y=tp[i][j];
            if(c[y]<tp[i].size()-j) return false;
        }
    }
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    IOS;
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) cin>>c[i];
    int l=1,r=n,ans;
    while(l<=r)
    {
        if(chk(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    for(int i=1;i<=ans;i++)
    {
        for(int j=i;j<=n;j+=ans)
            vec[i].push_back(a[j]);
        cout<<vec[i].size();
        for(auto it:vec[i]) cout<<' '<<it;
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
vector<int>vec[maxn];
int n,k;
bool chk(int x)
{
    for(int i=1;i<=x;i++)
    {
        int m=(n-i)/x;
        if(c[a[m*x+i]]<m+1) return false;
    }
    return true;
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) cin>>c[i];
    int l=1,r=n,ans;
    while(l<=r)
    {
        if(chk(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    for(int i=1;i<=ans;i++)
    {
        for(int j=i;j<=n;j+=ans)
            vec[i].push_back(a[j]);
        cout<<vec[i].size();
        for(auto it:vec[i]) cout<<' '<<it;
        cout<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
vector<int>vec[maxn];
int n,k;
bool chk(int x)
{
    for(int i=1;i<=x;i++)
    {
        int m=(n-i)/x;
        if(c[a[m*x+i]]<m+1) return false;
    }
    return true;
}
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=k;i++) cin>>c[i];
    int l=1,r=n,ans;
    while(l<=r)
    {
        if(chk(mid)) ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    for(int i=1;i<=ans;i++)
    {
        for(int j=i;j<=n;j+=ans)
            vec[i].push_back(a[j]);
        cout<<vec[i].size();
        for(auto it:vec[i]) cout<<' '<<it;
        cout<<endl;
    }
}
//


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
#define ld long double
#define mid (l+r)/2
#define ll long long
#define ls o*2
#define rs o*2+1
typedef pair<int,int> pii;
const int maxn=200005;
int a[maxn],c[maxn];
int main()
{
    #ifdef local
    freopen("in.txt","r",stdin);
    #endif // local
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<k;i++) cin>>c[i];
    int mx=0;
    for(int i=0;i<n;i++)
    {
        mx=max(mx,(n-i+c[a[i]-1]-1)/c[a[i]-1]);
    }
    cout<<mx<<endl;
    for(int i=0;i<mx;i++)
    {
        cout<<(n-1-i)/mx+1;
        for(int j=i;j<n;j+=mx) cout<<' '<<a[j];
        cout<<endl;
    }
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	sort(a.begin(), a.end());
	vi lb(n);
	int iter = k-1;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter] < i+1)  iter--;
		lb[i] = iter + 1;
	}
	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while (iter > 0 && a[iter] > lb[cnt-1]) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	sort(a.begin(), a.end());
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while (iter > 0 && a[iter] > lb[cnt-1]) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		assert(!ret.empty());
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while ((iter >= a.size() && iter > 0) || (iter > 0 && a[iter] > lb[cnt-1])) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
//			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		assert(!ret.empty());
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	sort(a.begin(), a.end());
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vi ret;
	while (!a.empty()) {
		ret.clear();
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while (iter > 0 && a[iter] > lb[cnt-1]) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
			if (iter != 0) --iter;
			cnt++;
		}
		cout << ret.size() << " ";
		PRSP(ret, ret.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int find(vi &a, vi &lb, int cnt) {
	int lo = 0, hi = a.size() - 1;
	while (lo < hi) {
		int mid = (lo + hi + 1) / 2;
		if (a[mid] > lb[cnt-1]) hi = mid - 1;
		else lo = mid;
	}
	return lo;
}

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int cnt = 1;
		int iter = find(a, lb, cnt);
		while (true) {
			if (a.empty()) break;
			while ((iter >= a.size() && iter > 0) || (iter > 0 && a[iter] > lb[cnt-1])) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
//			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		assert(!ret.empty());
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			if (a.empty()) break;
			while ((iter >= a.size() && iter > 0) || (iter > 0 && a[iter] > lb[cnt-1])) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
//			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		assert(!ret.empty());
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	sort(a.begin(), a.end());
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while (iter > 0 && a[iter] > lb[cnt-1]) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	sort(a.begin(), a.end());
	vi lb(n);
	int iter = k-1;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter] < i+1)  iter--;
		lb[i] = iter + 1;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int iter = a.size()-1;
		int cnt = 1;
		while (true) {
			while (iter > 0 && a[iter] > lb[cnt-1]) --iter;
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<pair<int, int>, int> ppi;
typedef pair<int, pair<int, int> > pip;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'

#define FOR(i, a, b) for (int (i) = (a); i < (b); ++i)
#define FORd(i, a, b) for (int (i) = (a); i >= (b); --i)
#define TRAV(i, x) for (auto& (i) : (x))
#define PRSP(x, a) for (int rv = 0; rv < a; ++rv) {cout << ((rv==0 ? "" : " ")) << x[rv];} cout << endl;
#define mppi(a, b, c) mp(mp((a), (b)), (c))
#define mpip(a, b, c) mp((a), mp((b), (c)))
#define max3(a, b, c) max(max((a), (b)), (c))
#define min3(a, b, c) min(min((a), (b)), (c))

void setIO(string name = "") {
	ios_base::sync_with_stdio(0); cin.tie(0);
	if (name == "") return;
	if (name == "input") {freopen("input.txt","r",stdin);}
	else {freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
}

const int INF = INT_MAX;
const int NINF = INT_MIN;
const int MAXLOG = 21;
const int MAXSEG = (1<<18);
const int MUL = 1000001;
const int MOD = 1000000007;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };

int find(vi &a, vi &lb, int cnt) {
	int lo = 0, hi = a.size() - 1;
	while (lo < hi) {
		int mid = (lo + hi + 1) / 2;
		if (a[mid] > lb[cnt-1]) hi = mid - 1;
		else lo = mid;
	}
	return lo;
}

int main() {
	chrono::high_resolution_clock::time_point t0 = chrono::high_resolution_clock::now();

	setIO();
	int n, k;
	cin >> n >> k;
	vi a(n);
	FOR (i, 0, n) cin >> a[i];
	sort(a.begin(), a.end());
	vi c(k);
	FOR (i, 0, k) cin >> c[i];
	vi lb(n);
	int iter = k;
	FOR (i, 0, n) {
		while (iter > 0 && c[iter-1] < i+1)  iter--;
		lb[i] = iter;
	}
//	PRSP(lb, lb.size());
	vector<vi> ans;
	while (!a.empty()) {
		vi ret;
		int cnt = 1;
		int iter = find(a, lb, cnt);
		while (true) {
			if (a.empty()) break;
			iter = find(a, lb, cnt);
			if (iter == 0 && a[iter] > lb[cnt-1]) break;
			ret.pb(a[iter]);
			a.erase(a.begin() + iter);
//			if (iter != 0) --iter;
			cnt++;
		}
		/*cout << ret.size() << " ";
		PRSP(ret, ret.size());*/
		assert(!ret.empty());
		ans.pb(ret);
	}
	cout << ans.size() << endl;
	TRAV (x, ans) {
		cout << x.size() << " ";
		PRSP(x, x.size());
	}

	chrono::high_resolution_clock::time_point t1 = chrono::high_resolution_clock::now();
//	cout << "TIME: " << chrono::duration_cast<chrono::milliseconds>(t1 - t0).count() << " ms" << endl;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp;

void init() {
	v = vi(n);
	c = vi(m);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end(), greater<int>());

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);
}

void solve() {
	vvi ans;

	while (pv.size() > 0) {
		vi tmp, nxtV, nxtC, nxtP;
		int pre = -1;

		// assert(pc.size() == pv.size()); assert(pc.size() == pp.size());

		int cnt = 0;
		for (int i = 0; i < pc.size(); i++) {
			int cc = pc[i], vv = pv[i];

			if (vv == cc - cnt) { // use up to all test cases
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				cnt += vv;
			} else if (vv > cc - cnt) { // have more test cases than allowed
				for (int j = 1; j <= (cc - cnt); j++) tmp.pb(pp[i]);
				nxtV.pb(vv - cc + cnt);
				nxtC.pb(cc);
				nxtP.pb(pp[i]);
				cnt += cc - cnt;
			} else { // all test cases can be put into the test
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				cnt += vv;
			}
		}
		ans.pb(tmp);
		pv = nxtV;
		pc = nxtC;
		pp = nxtP;
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}

	// debug
	// cout << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp, np;

void init() {
	v = vi(n);
	c = vi(m);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end(), greater<int>());

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);

	int sz = pv.size();
	np = vi(sz);
	np[sz - 1] = sz;
	for (int i = sz - 2; i >= 0; i--) {
		if (pc[i] != pc[i + 1]) np[i] = i + 1;
		else np[i] = np[i + 1];
	}
}

void solve() {
	vvi ans;
	int remain = n, start = 0;

	while (remain > 0) {
		//for (int k = 0; k < np.size(); k++) cout << np[k] << " "; cout << endl;
		//for (int k = 0; k < pv.size(); k++) cout << pv[k] << " "; cout << endl;

		vi tmp;
		int pre = -1;

		int cnt = 0, i = start;
		while (i < pv.size() && pv[i] == 0) i++;
		start = i;

		while (i < pc.size()) {
			int cc = pc[i], vv = pv[i], nxt = np[i];
			// cout << "cur " << i << " " << cc << " " << vv << " " << cnt << endl;

			if (vv > cc - cnt) {
				int num = max(0, cc - cnt);
				for (int j = 1; j <= num; j++) tmp.pb(pp[i]);
				pv[i] -= num;
				remain -= num;
				cnt += num;
			} else {
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				pv[i] -= vv;
				remain -= vv;
				cnt += vv;
				nxt = i + 1;
				if (i == np.size() - 1) np[i] = np.size();
				else np[i] = np[i + 1];
			}
			i = nxt;
		}
		ans.pb(tmp);
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef map<int, int> mii;

int n, m;
vi v, c;
mii cnt;

void init() {
	v = vi(n, 0);
	c = vi(m, 0);
	cnt.clear();
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i]--;
		cnt[v[i]]++;
	}
	for (int i = 0; i < m; i++) cin >> c[i];
}

void solve() {
	vvi ans;

	int p = 0;
	for (int i = m - 1; i >= 0; i--) {
		if (i + 1 < m && c[i] > c[i + 1]) p = 0;
		for (int j = 0; j < cnt[i]; j++) {
			while (p < ans.size() && ans[p].size() + 1 > c[i]) p++;
			if (p == ans.size()) ans.pb(vi(1, i));
			else ans[p].pb(i);
		}
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp;

void init() {
	v = vi(n, 0);
	c = vi(m, 0);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end());

	pc.clear();
	pv.clear();
	pp.clear();

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);
}

void solve() {
	vvi ans;
	int remain = n, start = 0;

	int total = 0;
	while (remain > 0) {
		// for (int k = 0; k < pv.size(); k++) cout << pv[k] << " "; cout << endl;

		vi tmp;
		int i = start;
		int cnt = pc[i];

		while (i < pc.size()) {
			start = i;
			total++;
			int cc = min(cnt, pc[i]), vv = pv[i];
			// cout << "cur " << i << " " << cc << " " << vv << " " << endl;

			if (vv > cc) {
				for (int j = 1; j <= cc; j++) tmp.pb(pp[i]);
				pv[i] -= cc;
				remain -= cc;
				break;
			} else {
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				pv[i] -= vv;
				remain -= vv;
				cnt = min(cnt - vv, pc[i] - vv);
				i++;
			}
		}
		ans.pb(tmp);
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}

	// cout << "debug total " << total << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp;

void init() {
	v = vi(n);
	c = vi(m);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end(), greater<int>());

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);
}

void solve() {
	vvi ans;
	int remain = n;

	while (remain > 0) {
		vi tmp, nxtV, nxtC, nxtP;
		int pre = -1;

		int cnt = 0;
		for (int i = 0; i < pc.size(); i++) {
			int cc = pc[i], vv = pv[i];

			if (vv > cc - cnt) {
				for (int j = 1; j <= (cc - cnt); j++) tmp.pb(pp[i]);
				nxtV.pb(vv - cc + cnt);
				nxtC.pb(cc);
				nxtP.pb(pp[i]);
				remain -= (cc - cnt);
				cnt += cc - cnt;
			} else {
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				remain -= vv;
				cnt += vv;
			}
		}
		ans.pb(tmp);
		pv = nxtV;
		pc = nxtC;
		pp = nxtP;
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp;

void init() {
	v = vi(n);
	c = vi(m);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end(), greater<int>());

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);
}

void solve() {
	vvi ans;

	while (pv.size() > 0) {
		vi tmp, nxtV, nxtC, nxtP;
		int pre = -1;

		assert(pc.size() == pv.size());
		assert(pc.size() == pp.size());

		int cnt = 0;
		for (int i = 0; i < pc.size(); i++) {
			int cc = pc[i], vv = pv[i];

			if (vv == cc - cnt) { // use up to all test cases
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				cnt += vv;
			} else if (vv > cc - cnt) { // have more test cases than allowed
				for (int j = 1; j <= (cc - cnt); j++) tmp.pb(pp[i]);
				nxtV.pb(vv - cc + cnt);
				nxtC.pb(cc);
				nxtP.pb(pp[i]);
				cnt += cc - cnt;
			} else { // all test cases can be put into the test
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				cnt += vv;
			}
		}
		ans.pb(tmp);
		pv = nxtV;
		pc = nxtC;
		pp = nxtP;
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}

	// debug
	// cout << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef map<int, int> mii;

int n, m;
vi v, c;
mii cnt;

void init() {
	v = vi(n, 0);
	c = vi(m, 0);
	cnt.clear();
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i]--;
		cnt[v[i]]++;
	}
	for (int i = 0; i < m; i++) cin >> c[i];
}

void solve() {
	vvi ans;

	int p = 0;
	for (int i = m - 1; i >= 0; i--) {
		p = 0;
		for (int j = 0; j < cnt[i]; j++) {
			while (p < ans.size() && ans[p].size() + 1 > c[i]) p++;
			if (p == ans.size()) ans.pb(vi(1, i));
			else ans[p].pb(i);
		}
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;

int n, m;
vi v, c;
vi pc, pv, pp, np;

void init() {
	v = vi(n);
	c = vi(m);
	for (int i = 0; i < n; i++) { cin >> v[i]; v[i]--; }
	for (int i = 0; i < m; i++) cin >> c[i];

	sort(v.begin(), v.end(), greater<int>());

	int pre = v[0], cnt = 1;
	for (int i = 1; i < n; i++) {
		if (pre == v[i]) {
			cnt++;
			continue;
		}
		pv.pb(cnt);
		pc.pb(c[pre]);
		pp.pb(pre);
		cnt = 1;
		pre = v[i];
	}
	pv.pb(cnt);
	pc.pb(c[pre]);
	pp.pb(pre);

	int sz = pv.size();
	np = vi(sz);
	np[sz - 1] = sz;
	for (int i = sz - 2; i >= 0; i--) {
		if (pc[i] != pc[i + 1]) np[i] = i + 1;
		else np[i] = np[i + 1];
	}
}

void solve() {
	vvi ans;
	int remain = n, start = 0;

	while (remain > 0) {
		//for (int k = 0; k < np.size(); k++) cout << np[k] << " "; cout << endl;
		//for (int k = 0; k < pv.size(); k++) cout << pv[k] << " "; cout << endl;

		vi tmp;
		int pre = -1;

		int cnt = 0, i = start;
		while (i < pv.size() && pv[i] == 0) i++;
		start = i;

		while (i < pc.size()) {
			// cout << "cur " << i << endl;
			int cc = pc[i], vv = pv[i], nxt = np[i];

			if (vv > cc - cnt) {
				for (int j = 1; j <= (cc - cnt); j++) tmp.pb(pp[i]);
				pv[i] -= (cc - cnt);
				remain -= (cc - cnt);
				cnt += cc - cnt;
			} else {
				for (int j = 1; j <= vv; j++) tmp.pb(pp[i]);
				pv[i] -= vv;
				remain -= vv;
				cnt += vv;
				nxt = i + 1;
				if (i == np.size() - 1) np[i] = np.size();
				else np[i] = np[i + 1];
			}
			i = nxt;
		}
		ans.pb(tmp);
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		//break;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vp;
typedef map<int, int> mii;

int n, m;
vi v, c;
mii cnt;

void init() {
	v = vi(n, 0);
	c = vi(m, 0);
	cnt.clear();
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		v[i]--;
		cnt[v[i]]++;
	}
	for (int i = 0; i < m; i++) cin >> c[i];
}

void solve() {
	vvi ans;

	int p = 0;
	for (int i = m - 1; i >= 0; i--) {
		//if (i + 1 < m && c[i] > c[i + 1]) p = 0;
		for (int j = 0; j < cnt[i]; j++) {
			while (p < ans.size() && ans[p].size() + 1 > c[i]) p++;
			if (p == ans.size()) ans.pb(vi(1, i));
			else ans[p].pb(i);
		}
	}

	cout << ans.size() << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].size();
		for (int j = 0; j < ans[i].size(); j++) cout << " " << ans[i][j] + 1;
		cout << endl;
	}
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int T;
	while (cin >> n >> m) {
		init();
		solve();
		// break;
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    vector<int> c(k);
    for(int i = 0; i < k; i++){
        cin >> c[i];
    }
    reverse(c.begin(), c.end());
    vector<vector<int> > ans; ans.pb({});
    int MIN = c[k - arr[0]];
    vector<int> c1 = c;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        MIN = min(c1[k - arr[i]] - 1, MIN - 1);
        c1[k - arr[i]]--;
        ans[cnt].pb(arr[i]);
        if(MIN == 0){
            c1 = c;
            ans.pb({});
            cnt++;
            MIN = 1e9;
        }
    }
    if(ans[ans.size() - 1].size() == 0)cnt--;
    cout << cnt + 1<< endl;
    for(int i = 0; i < cnt + 1; i++){
        cout << ans[i].size() << " ";
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        arr[i]--;
    }
    sort(arr, arr+n); reverse(arr, arr + n);
    vector<int> c(k);
    for(int i = 0; i < k; i++){
        cin >> c[i];
    }
    vector<vector<int> > ans;
    for(int i = 0; i < n; i++){
        int lo = 0; int hi = ans.size() - 1; int mid; int best = ans.size();
        while(lo <= hi){
            mid = (lo+hi)/2;
            if(ans[mid].size() >= c[arr[i]]){
                lo = mid + 1;
            }
            else{
                hi = mid - 1;
                best = mid;
            }
        }
        if(best == ans.size()){
            ans.pb({});
        }
        ans[best].pb(arr[i] + 1);
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i].size() << " ";
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    vector<int> c(k);
    for(int i = 0; i < k; i++){
        cin >> c[i];
    }
    reverse(c.begin(), c.end());
    vector<vector<int> > ans; ans.pb({});
    vector<int> c1 = c;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        //cout << "hi " << arr[i];
        c1[k - arr[i]]--;
        ans[cnt].pb(arr[i]);
        if(c1[k - arr[i]] == 0){
            c1 = c;
            ans.pb({});
            cnt++;
        }
    }
    if(ans[ans.size() - 1].size() == 0)cnt--;
    cout << cnt + 1<< endl;
    for(int i = 0; i < cnt + 1; i++){
        cout << ans[i].size() << " ";
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    vector<int> c(k);
    for(int i = 0; i < k; i++){
        cin >> c[i];
    }
    reverse(c.begin(), c.end());
    vector<vector<int> > ans; ans.pb({});
    int MIN = 1e9;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        MIN = min(c[k - arr[i]] - 1, MIN - 1);
        ans[cnt].pb(arr[i]);
        if(MIN == 0){
            ans.pb({});
            cnt++;
            MIN = 1e9;
        }
    }
    if(ans[ans.size() - 1].size() == 0)cnt--;
    cout << cnt + 1<< endl;
    for(int i = 0; i < cnt + 1; i++){
        cout << ans[i].size() << " ";
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007

int main(){
    FAST
    int n, k; cin >> n >> k;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    vector<int> c(k);
    for(int i = 0; i < k; i++){
        cin >> c[i];
    }
    reverse(c.begin(), c.end());
    vector<vector<int> > ans; ans.pb({});
    int MIN = c[k - arr[0]];
    vector<int> c1 = c;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        MIN = min(c1[k - arr[i]] - 1, MIN - 1);
        ans[cnt].pb(arr[i]);
        if(MIN == 0){
            c1 = c;
            ans.pb({});
            cnt++;
        }
    }
    if(ans[ans.size() - 1].size() == 0)cnt--;
    cout << cnt + 1<< endl;
    for(int i = 0; i < cnt + 1; i++){
        cout << ans[i].size() << " ";
        for(int j = 0; j < ans[i].size(); j++){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


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

//#define int long long

const int MAXN = 2e5 + 10;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,k,ans,all,tot;
int m[MAXN],c[MAXN];
int cnt[MAXN];
vector<int> v[MAXN];

signed main () {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	all = n;
	for(register int i = 1;i <= n; ++i) {
		cin >> m[i];
		cnt[m[i]]++;
	}
	for(register int i = 1;i <= k; ++i)
		cin >> c[i];
	while(all) {
		tot++;
		ans = 0;
		for(register int i = k;i >= 1; --i) {
			while(cnt[i] && ans < c[i]) {
				v[tot].push_back(i);
				cnt[i]--;
				all--;
				ans++;
			}
		}
	}
	cout << tot << endl;
	for(register int i = 1;i <= tot; ++i) {
		int len = v[i].size();
		cout << len << ' ';
		for(register int j = 0;j < len; ++j)
			cout << v[i][j] << ' ';
		cout << endl;
	}
	return 0;
}


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

//#define int long long

const int MAXN = 2e5 + 10;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,k,ans,all,tot;
int m[MAXN],c[MAXN];
int cnt[MAXN];
vector<int> v[MAXN];

signed main () {
	cin >> n >> k;
	all = n;
	for(register int i = 1;i <= n; ++i) {
		cin >> m[i];
		cnt[m[i]]++;
	}
	for(register int i = 1;i <= k; ++i)
		cin >> c[i];
	while(all) {
		tot++;
		ans = 0;
		for(register int i = k;i >= 1; --i) {
			while(cnt[i] && ans < c[i]) {
				v[tot].push_back(i);
				cnt[i]--;
				all--;
				ans++;
			}
		}
	}
	cout << tot << endl;
	for(register int i = 1;i <= tot; ++i) {
		int len = v[i].size();
		cout << len << ' ';
		for(register int j = 0;j < len; ++j)
			cout << v[i][j] << ' ';
		cout << endl;
	}
	return 0;
}