import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    static FastReader read;

    public static void main(String[] args) throws IOException {
        FastReader read = new FastReader();
        StringBuilder out = new StringBuilder();
        int n = read.nextInt();
        List<Integer> l[] = new ArrayList[n];
        Pair[] q = new Pair[n];
        boolean[] isAns = new boolean[n];

        for (int i = 0; i < n; i++) {
            int len = read.nextInt();
            l[i] = new ArrayList<>();
            q[i] = new Pair();
            for (int j = 0; j < len; j++) {
                int cur = read.nextInt();
                l[i].add(cur);
                q[i].mn = Math.min(q[i].mn, cur);
                q[i].mx = Math.max(q[i].mx, cur);
                if (cur > q[i].mn) {
                    isAns[i] = true;
                }
            }
        }
        long ans = 0;
        int arrs = n;
        for (int i = 0; i < n; i++) {
            if (isAns[i]) {
                arrs--;
                ans += 1;
                ans += (arrs * 2);
            }
        }
        List<Integer> maxs = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            if (!isAns[i]) {
                maxs.add(q[i].mx);
            }
        }

        Collections.sort(maxs);
        for (int i = 0; i < n; i++) {
            if (!isAns[i]) {
                int get = greaterv2(q[i].mn, maxs);
                ans += get;
            }
        }

        System.out.println(ans);

    }

    public static int greaterv2(int find, List<Integer> maxs) {
        if (maxs.get(0) > find) {
            return maxs.size();
        }
        int best = Collections.binarySearch(maxs, find);
        for (int i = 0; i < maxs.size(); i++) {
            if (maxs.get(i) > find) {
                best = i;
                break;
            }
        }
        if (best == maxs.size() - 1 && maxs.get(maxs.size() - 1) == find) {
            return 0;
        }
        return maxs.size() - best;
    }

    public static int greater(int find, List<Integer> maxs) {
        if (maxs.get(0) > find) {
            return maxs.size();
        }
        int mn = 0;
        int mx = maxs.size() - 1;
        int md = 0;
        int best = 0;

        while (mn <= mx) {
            md = (mn + mx) / 2;
            if (maxs.get(md) > find) {
                mx = md - 1;
            } else if (maxs.get(md) < find) {
                mn = md + 1;
            } else {
                best = md;
                mn = md + 1;
            }
        }

        for (int i = best; i < maxs.size(); i++) {
            if (maxs.get(i) > find) {
                best = i;
                break;
            }
        }
        if (best == maxs.size() - 1 && maxs.get(maxs.size() - 1) == find) {
            return 0;
        }
        return maxs.size() - best;
    }

}

class Pair {

    public int mn;
    public int mx;

    public Pair() {
        this.mn = Integer.MAX_VALUE;
        this.mx = Integer.MIN_VALUE;
    }

}

class FastReader {

    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}


import java.util.*;
import java.io.*;

public class Solution {
  public static void main(String[] args) throws IOException {
    FastReader in = new FastReader();
    PrintWriter pw = new PrintWriter(System.out);
    int seqN = in.nextInt();
    Seq[] seq = new Seq[seqN];

    for (int i = 0; i < seqN; i++) {
      int n = in.nextInt();
      int max = Integer.MIN_VALUE;
      int min = Integer.MAX_VALUE;
      int prev = 0;
      boolean isInc = false;

      for (int j = 0; j < n; j++) {
        int next = in.nextInt();
        if (j >= 1 && next > prev) isInc = true;
        prev = next;
        max = Math.max(max, next);
        min = Math.min(min, next);
      }

      seq[i] = new Seq(max, min, isInc);
    }

    int ans = 0;

    for (int i = 0; i < seqN; i++) {
      for (int j = 0; j < seqN; j++) {
        if (isInc(seq[i], seq[j])) ans++;
      }
    }

    pw.print(ans);
    pw.flush();
  }

  private static boolean isInc(Seq s1, Seq s2) {
    return s1.isInc || s2.isInc || s2.max > s1.min;
  }
}

class Seq {
  public int max;
  public int min;
  public boolean isInc;
  public Seq(int _max, int _min, boolean inc) {
    max = _max;
    min = _min;
    isInc = inc;
  }
}

class FastReader
{
  BufferedReader br;
  StringTokenizer st;

  public FastReader()
  {
    br=new BufferedReader(new InputStreamReader(System.in));
  }

  public String next() throws IOException
  {
    if(st==null || !st.hasMoreElements())
    {
      st=new StringTokenizer(br.readLine());
    }
    return st.nextToken();
  }

  public int nextInt() throws IOException
  {
    return Integer.parseInt(next());
  }

  public long nextLong() throws IOException
  {
    return Long.parseLong(next());
  }
}


//152875TP
//solution by IHKIM
//WRONG ANSWER
#include<iostream>
#include<cmath>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<math.h>
#include<time.h>
#include<queue>
#include<stack>
#include<deque>

//TEMPLATE STARTS HERE
using namespace std;

//constants
const int MAXN=(int)(1e5+1e1);
const double PI=acos(-1.0);

//defines
#define ll long long
#define F first
#define S second
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define mp make_pair
#define pb push_back
#define eof (-1)
#define forr(xx,yy,zz) for(int zz=xx;zz<=yy;zz++)
#define forl(xx,yy,zz) for(int zz=xx;zz>=yy;zz--)
#define sqr(x) ((x)*(x))
#define sz(x) (int)x.size()
#define len(s) (int)(s.length())
#define all(a) a.begin(),a.end()
vector<int> v;
ll n,k,q;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	forr(0,n-1,i)
		cin>>q,v.pb(q);
	sort(all(v));
	for(int i = 0; i < n && k > 0; i++,k--)
        cout<<1<<" "<<v[i]<<'\n';
	for(int i = n - 1; i > 0; i--)
    {
        for(int j = i - 1; j >= 0 && k > 0; j--,k--)
        {
            cout<<n - i + 1<<" ";
            for(int e = n - 1; e >= i; e--)
                cout<<v[e]<<" ";
            cout<<v[j]<<'\n';
        }
    }
	return 0;
}


//152875TP
//solution by IHKIM
//WRONG ANSWER
#include<iostream>
#include<cmath>
#include<fstream>
#include<cstdio>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<math.h>
#include<time.h>
#include<queue>
#include<stack>
#include<deque>

//TEMPLATE STARTS HERE
using namespace std;

//constants
const int MAXN=(int)(1e5+1e1);
const double PI=acos(-1.0);

//defines
#define ll long long
#define F first
#define S second
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
#define mp make_pair
#define pb push_back
#define eof (-1)
#define forr(xx,yy,zz) for(int zz=xx;zz<=yy;zz++)
#define forl(xx,yy,zz) for(int zz=xx;zz>=yy;zz--)
#define sqr(x) ((x)*(x))
#define sz(x) (int)x.size()
#define len(s) (int)(s.length())
#define all(a) a.begin(),a.end()
vector<int> v[MAXN];
ll n,k,a[MAXN],w=1;
bool b[MAXN];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	forr(1,n,i)
		cin>>a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	if(n>=k)
	{
		for(int i=1;i<=k;i++)
		{
			v[i].pb(a[i]);
		}
	}
	else
	{
			int q=1;
			forr(1,k,i)
			{
				v[i].pb(a[q]);
				q++;
				if(b[w-1])
				{
					forr(1,w-1,j)
					{
						if(q+j<=n)
							v[i].pb(a[q+j]);
						else
							v[i].pb(a[j+1]);
					}
				}
				if(q==n+1)
					q=1,b[w]=1,w++;
			}
	}
	forr(1,k,i)
	{
		cout<<sz(v[i])<<' ';
		forr(0,sz(v[i])-1,j)
			cout<<v[i][j]<<' ';
		cout<<'\n';
	}
	return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctype.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <set>
#define pb push_back
#define sz size
#define str strlen
#define max(x,y) (x>y)?(x):(y)
#define min(x,y) (x<y)?(x):(y)
using namespace std;
set<int> fuck;
int table[52][52];
int main(){
    int n, k, i, j, l;
    scanf("%d%d", &n, &k);
    int* a=new int[n];
    for(i=0; i<n; ++i){
        scanf("%d",&a[i]);
        table[i][i]=a[i];
    }
    for(i=0; i<n-1; ++i)
        for(j=i+1; j<n; ++j)
            table[i][j]=table[i][j-1]+a[j];
    /*puts("table:");
    for(i=0; i<n; ++i){
        for(j=i; j<n; ++j)
            printf("%d ",table[i][j]);
        puts("");
    }
    puts("------");*/
    for(i=0; i<n && k; ++i)
        for(j=i; j<n && k; ++j){
            if(fuck.find(table[i][j])==fuck.end()) {
                fuck.insert(table[i][j]);
                printf("%d ",j-i+1);
                for(l=i; l<=j; ++l) printf("%d ",a[l]);
                puts("");
                --k;
            }
        }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int a[51];
int cmp(const void* p, const void* q){
    return (*(int *)p - *(int *)q);
}

int main(){
    int n, k, i, j, l;
    scanf("%d%d",&n, &k);
    int cnt=k;
    for(i=0; i<n; ++i)  scanf("%d",&a[i]);
    qsort(a, n, sizeof(n), cmp);
    for(i=n-1; i>=0 && cnt; --i)
        for(j=0; j<=i && cnt; ++j){
            printf("%d %d", n-i, a[j]);
            for(l=1; l<n-i; ++l) printf(" %d", a[n-l]);
            puts("");
            --cnt;
        }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;

int a[51];
int cmp(const void* p, const void* q){
    return (*(int *)p > *(int *)q);
}

int main(){
    int n, k, i, j, l;
    scanf("%d%d",&n, &k);
    int cnt=k;
    for(i=0; i<n; ++i)  scanf("%d",&a[i]);
    qsort(a, n, sizeof(n), cmp);
    for(i=n-1; i>=0 && cnt; --i)
        for(j=0; j<=i && cnt; ++j){
            printf("%d %d", n-i, a[j]);
            for(l=1; l<n-i; ++l) printf(" %d", a[n-l]);
            puts("");
            --cnt;
        }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <climits>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pi acos(-1.0)
#define EPS 1e-9

using namespace std;
int arr[59],v[59];
int main()
{
	map<int,bool> m;
	int n,k;scanf("%d %d",&n,&k);
	memset(arr,0,sizeof(arr));
	scanf("%d",&v[1]);arr[1]=v[1];
	for(int i=2;i<=n;i++){
		scanf("%d",&v[i]);
		arr[i]=arr[i-1]+v[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			int sum=arr[i]-arr[j-1];
			if(m[sum])continue;
			m[sum]=1;k--;
			printf("%d ",(i-j+1));
			for(int x=j;x<i;x++)printf("%d ",v[x]);
			printf("%d\n",v[i]);
			if(k==0)return 0;
		}
	}
	return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <climits>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pi acos(-1.0)
#define EPS 1e-9

using namespace std;
int arr[59];
int main()
{
	map<int,bool> m;
	int n,k;scanf("%d %d",&n,&k);for(int i=0;i<n;i++)scanf("%d",arr+i);
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
		printf("1 %d\n",arr[i]);k--;
		m[arr[i]]=1;
		if(k==0)return 0;
	}
	for(int i=0;i<n;i++){
		int sum=arr[i];
		for(int j=n-1;j>i;j--){
			sum+=arr[j];
			if(m[sum])continue;
			m[sum]=1;k--;
			printf("%d %d",((n-1)-j)+2,arr[i]);
			for(int x=n-1;x>=j;x--)printf(" %d",arr[x]);
			printf("\n");
			if(k==0)return 0;
		}
	}
	return 0;
}


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

#include<cmath>
#include<iostream>
#include<fstream>
#include<numeric>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iterator>

using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define int64 long long
#define pb push_back
#define mp make_pair
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define infinity 2147483647
#define FRO freopen("in.txt","r",stdin);
#define FRU freopen("out.txt","w",stdout);
#define MAX 205

main()
{
    int i,j,k,a,b,c,n;
    cin>>n>>k;
    for(i=0;i<n;i++)cin>>a;
    b=1;
    for(i=1;i<=k;i++)
    {
        cout<<i<<" "<<a;
        for(j=1;j<i;j++)cout<<" "<<a;
        cout<<endl;
    }
}


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

#include<cmath>
#include<iostream>
#include<fstream>
#include<numeric>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iterator>

using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define int64 long long
#define pb push_back
#define mp make_pair
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define infinity 2147483647
#define FRO freopen("in.txt","r",stdin);
#define FRU freopen("out.txt","w",stdout);
#define MAX 205

main()
{
    int i,j,k,n,a,b,c,ar[55];

    cin>>n>>k;
    for(i=0;i<n;i++)cin>>ar[i];

    int koyta=0,ekhon=0;
    for(i=0;i<k;i++)
    {
        cout<<koyta+1;
        for(j=0;j<koyta;j++)cout<<" "<<ar[j];
        cout<<" "<<ar[ekhon]<<endl;
        ekhon==n-1? ekhon=++koyta : ekhon++;
    }
}


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

#include<cmath>
#include<iostream>
#include<fstream>
#include<numeric>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#include<list>
#include<iterator>

using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define int64 long long
#define pb push_back
#define mp make_pair
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
#define infinity 2147483647
#define FRO freopen("in.txt","r",stdin);
#define FRU freopen("out.txt","w",stdout);
#define MAX 205

bool cmp(int a,int b)
{
    return a>b;
}

main()
{
    int i,j,k,n,a,b,c,ar[55];

    cin>>n>>k;
    for(i=0;i<n;i++)cin>>ar[i];

    sort(ar,ar+n,cmp);

    int koyta=0,ekhon=0;
    for(i=0;i<k;i++)
    {
        cout<<koyta+1;
        for(j=0;j<koyta;j++)cout<<" "<<ar[j];
        cout<<" "<<ar[ekhon]<<endl;
        ekhon==n-1? ekhon=++koyta : ekhon++;
    }
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];
const int maxt = 25;
int ss[1<<maxt];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (all.insert(s).second) return;
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=0;
  go(l+1,s,cnt);
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  n=50;
  k=1192;
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    x=i+1;
    a[i]=x;
  }
  srand(123);
  random_shuffle(a,a+n);
  sort(a,a+n,greater<int>());

  for (int st = 0;0&&st<n;){
    int g = min(n-st,maxt);
    for (int i = 0; i < bit(g); i++) {
      if (all.insert(ss[st+i]).second) {
        vector<int> v;
        for (int j = 0; j < g; j++) {
          if (bit(j)&i) {
            v.push_back(a[st+j]);
          }
        }
        printf("%d",v.size());
        for (int x : v) {
          printf(" %d",x);
        }
        puts("");
        done++;
        if (done == k) {
          return 0;
        }
      }
      for (int j = 0; j < g; j++) {
        if (bit(j)&i) {
          break;
        } else {
          ss[i|bit(j)] = ss[i]+a[st+j];
        }
      }
    }
    st += g;
  }

  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (all.count(s)) return;
    all.insert(s);
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
  has[l]=0;
  go(l+1,s,cnt);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];
const int maxt = 25;
int ss[1<<maxt];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (!all.insert(s).second) return;
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=0;
  go(l+1,s,cnt);
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  srand(123);
  random_shuffle(a,a+n);
  //sort(a,a+n,greater<int>());
  sort(a,a+n);

  for (int st = 0;0&&st<n;){
    int g = min(n-st,maxt);
    for (int i = 0; i < bit(g); i++) {
      if (all.insert(ss[st+i]).second) {
        vector<int> v;
        for (int j = 0; j < g; j++) {
          if (bit(j)&i) {
            v.push_back(a[st+j]);
          }
        }
        printf("%d",v.size());
        for (int x : v) {
          printf(" %d",x);
        }
        puts("");
        done++;
        if (done == k) {
          return 0;
        }
      }
      for (int j = 0; j < g; j++) {
        if (bit(j)&i) {
          break;
        } else {
          ss[i|bit(j)] = ss[i]+a[st+j];
        }
      }
    }
    st += g;
  }

  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];
const int maxt = 25;
int ss[1<<maxt];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (all.insert(s).second) return;
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=0;
  go(l+1,s,cnt);
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  srand(123);
  random_shuffle(a,a+n);
  sort(a,a+n,greater<int>());

  for (int st = 0;0&&st<n;){
    int g = min(n-st,maxt);
    for (int i = 0; i < bit(g); i++) {
      if (all.insert(ss[st+i]).second) {
        vector<int> v;
        for (int j = 0; j < g; j++) {
          if (bit(j)&i) {
            v.push_back(a[st+j]);
          }
        }
        printf("%d",v.size());
        for (int x : v) {
          printf(" %d",x);
        }
        puts("");
        done++;
        if (done == k) {
          return 0;
        }
      }
      for (int j = 0; j < g; j++) {
        if (bit(j)&i) {
          break;
        } else {
          ss[i|bit(j)] = ss[i]+a[st+j];
        }
      }
    }
    st += g;
  }

  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];
const int maxt = 25;
int ss[1<<maxt];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (!all.insert(s).second) return;
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=0;
  go(l+1,s,cnt);
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  srand(123);
  random_shuffle(a,a+n);
  sort(a,a+n,greater<int>());
  //sort(a,a+n);

  for (int st = 0;st<n;){
    int g = min(n-st,maxt);
    for (int i = 0; i < bit(g); i++) {
      if (all.insert(ss[st+i]).second) {
        vector<int> v;
        for (int j = 0; j < g; j++) {
          if (bit(j)&i) {
            v.push_back(a[st+j]);
          }
        }
        printf("%d",v.size());
        for (int x : v) {
          printf(" %d",x);
        }
        puts("");
        done++;
        if (done == k) {
          return 0;
        }
      }
      for (int j = 0; j < g; j++) {
        if (bit(j)&i) {
          break;
        } else {
          ss[i|bit(j)] = ss[i]+a[st+j];
        }
      }
    }
    st += g;
  }

  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];

void go(int l, int s, int cnt) {
  if (l==n) {
    if (all.count(s)) return;
    all.insert(s);
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
  has[l]=0;
  go(l+1,a[l],cnt);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  go(0, 0, 0);
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

const int maxn = 55;
int n,k,done;
map<int,int64> all;
int a[maxn];
const int maxv = 1<<24;
int was[maxv];

struct cmp {
  bool operator()(const pair<int,int>& a, const pair<int,int>& b) const {
    return a.first == b.first;
  }
};

int main() {
  cin >> n >> k;
  was[0]=1;
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  sort(a,a+n,greater<int>());
  was[0]=1;
  all[0]=0;
  for (int i = 0; done < k && i < n; i++) {
    for (map<int,int64>::iterator it = all.begin(); done < k && it != all.end(); ++it) {
      if (it->second&bit(i)) continue;
      int s = it->first+a[i];
      if (all.count(s)) continue;
      all[s] = it->second | bit(i);
      done++;
    }
  }
  for (const auto& x : all) {
    if (!x.first) continue;
    int z = 0;
    int64 v = x.second;
    for (int j = 0; j < n; j++) if (bit(j)&v) z++;
    printf("%d",z);
    for (int j = 0; j < n; j++) if (bit(j)&v) printf(" %d",a[j]);
    puts("");
  }
  return 0;
}


#pragma comment(linker, "/STACK:16777216")
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#ifndef ONLINE_JUDGE
#define Eo(x) { cerr << #x << " = " << (x) << endl; }
#else
#define Eo(x)
#endif

typedef long long int64;
const int inf = 0x3f3f3f3f;
const int64 inf64 = 0x3f3f3f3f3f3f3f3fLL;
typedef double real;
const real eps = 1e-6;
typedef pair<int64,int64> pip;

int64 gcd(int64 a, int64 b) {
  return a ? gcd(b%a,a) : b;
}

template <typename A,typename B>
ostream& operator<<(ostream& os, const pair<A,B>& p) {
                 return os << p.first << "," << p.second;
}

template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
                 for (int i = 0; i < v.size(); i++) {
                   os << v[i] << ";";
                 }
                 return os;
}

template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
                 for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << *it << ";";
                 }
                 return os;
}

template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A,B>& v) {
                 for (typename map<A,B>::const_iterator it = v.begin(); it != v.end(); ++it) {
                   os << it->first << "=" << it->second << ";";
                 }
                 return os;
}

inline int64 bit(int64 k) {
  return int64(1)<<k;
}

int SolveSquareEquation(real a, real b, real c, real& x1, real& x2) {
  real desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc = sqrt(desc);
  x1 = (-b+sqrt_desc)/(2*a);
  x2 = (-b-sqrt_desc)/(2*a);
  if (desc<eps) {
    return 1;
  }
  return 2;
}

int SolveSquareEquationInt(int64 a, int64 b, int64 c, int64& x1, int64& x2) {
  int64 desc = b*b-4*a*c;
  if (desc<0) return 0;
  real sqrt_desc_r = sqrt(real(desc));
  int64 sqrt_desc = sqrt_desc_r;
  for (;sqrt_desc*sqrt_desc<desc; sqrt_desc++);
  for (;sqrt_desc*sqrt_desc>desc; sqrt_desc--);
  if (sqrt_desc*sqrt_desc != desc) {
    return 0;
  }
  int64 u1 = -b+sqrt_desc;
  int64 u2 = -b-sqrt_desc;
  int64 a2 = a*2;
  vector<int64> res;
  if (!(u1%a2)) {
    res.push_back(u1/a2);
  }
  if (!(u2%a2)) {
    res.push_back(u2/a2);
  }
  int oldsize = res.size();
  res.resize(2);
  x1=res[0];
  x2=res[1];
  return oldsize;
}

set<int> was;
const int maxn = 55;
int has[maxn];
int n,k,done;
set<int> all;
int a[maxn];
const int maxt = 25;
int ss[1<<maxt];

void go(int l, int s, int cnt) {
  if (l>=n) {
    if (!all.insert(s).second) return;
    printf("%d",cnt);
    for (int i = 0; i < n; i++) if (has[i]) {
      printf(" %d",a[i]);
    }
    puts("");
    done++;
    if (done==k) {
      exit(0);
    }
    return;
  }
  has[l]=0;
  go(l+1,s,cnt);
  has[l]=1;
  go(l+1,s+a[l],cnt+1);
}

int main() {
  cin >> n >> k;
  all.insert(0);
  for (int i = 0; i < n; i++) {
    int x; scanf("%d",&x);
    a[i]=x;
  }
  srand(123);
  random_shuffle(a,a+n);
  sort(a,a+n,greater<int>());

  for (int st = 0;0&&st<n;){
    int g = min(n-st,maxt);
    for (int i = 0; i < bit(g); i++) {
      if (all.insert(ss[st+i]).second) {
        vector<int> v;
        for (int j = 0; j < g; j++) {
          if (bit(j)&i) {
            v.push_back(a[st+j]);
          }
        }
        printf("%d",v.size());
        for (int x : v) {
          printf(" %d",x);
        }
        puts("");
        done++;
        if (done == k) {
          return 0;
        }
      }
      for (int j = 0; j < g; j++) {
        if (bit(j)&i) {
          break;
        } else {
          ss[i|bit(j)] = ss[i]+a[st+j];
        }
      }
    }
    st += g;
  }

  go(0, 0, 0);
  return 0;
}


// Exercício:
// Tempo para programar:
// Dificuldade:
// Tema:
// Complexidade: O( ? )

#include <cstdio>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

typedef int ll;

typedef vector<ll>vi;
typedef pair<ll,ll>ii;
typedef vector<ii>vii;

#define INF 0x3F3F3F3F
#define ler(x) scanf("%lld",&x);
#define imp(x) printf("%lld",x);
#define REP(n) for(ll i=0;i<n;++i)
#define PI 2*acos(0.0)
#define pb push_back
#define MAXN 100000

//g++ -std=c++11

ll n,k;
vi v;

int main()
{
	scanf("%d %d",&n,&k);
	ll x;
	for(int i=0;i<n;++i)
	{
		scanf("%d",&x);
		v.pb(x);
	}
	sort(v.begin(),v.end());

	for(int i = 0;i<n && k!=0;i++)
	{
        for(int j = 0;j<n-i && k!=0;j++)
        {
            printf("%d",i+1);
            for(int l = n-1;l>=n-i;l--) printf(" %d",v[l]);
            printf(" %d\n",v[j]);
            k--;
        }
    }
	//printf("%d\n",k);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<string>
#include<algorithm>
#include<iterator>
#include<set>
#include<deque>
#include<cctype>
#include<cassert>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<stack>
#include<bitset>
#include<map>
#include<utility>
#include<ctime>
#define clr(a,v) memset(a,v,sizeof(a));
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define sqr(a) a*a
const double eps=1e-8;
const int N = 111111;
const int mod = 1000000;
const double pi=acos(-1.0);
typedef long long ll;
const ll INF = 0x7f7f7f7f;
const double inf = 1e50;
template<class T> inline T minx(T a,T b) { return (a==-1||b<a)?b:a; }
template<class T> inline T gcd(T a,T b) { return b?gcd(b,a%b):a;}
template<class T> inline T lcm(T a,T b) { return a*(b/gcd(a,b));}
template<class T> inline T getbit(T n) { return n?(1+getbit(n&(n-1))):0;}
template<class T> inline T lowbit(T n) { return n&(-n);}
using namespace std;
typedef long long ll;
int c[N],a[N];
int cnt[N];
set<int>s[N];
map<ll,ll>p;
map<ll,ll>::iterator it;
int n,k;
void dfs(ll sum,int t,ll s)
{
	if(t>=n) return;
	int size=p.size();
	if(size>=k) return;
	if(sum>0&&s>0)
	{
		p[sum]=s;
	}
	int i;
	for(i=t+1;i<=n;i++)
	{
		dfs(sum+a[i],t+1,s|(1<<i));
	}
}
int main()
{
	ll t=1;
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",a+i);
	}
	sort(a+1,a+n);
	dfs(0,0,0);
	ll b;
	int st[100];
	int size;
	int cnt=0;
	for(it=p.begin();it!=p.end();it++)
	{
		cnt++;
		size=0;
		b=it->second;
		if(!b) continue;
		for(j=1;j<=50;j++)
		{
			if(b&(t<<j))
			{
				st[size++]=a[j];
			}
		}
		printf("%d",size);
		for(j=0;j<size;j++) printf(" %d",st[j]);
		puts("");
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<string>
#include<algorithm>
#include<iterator>
#include<set>
#include<deque>
#include<cctype>
#include<cassert>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<stack>
#include<bitset>
#include<map>
#include<utility>
#include<ctime>
#define clr(a,v) memset(a,v,sizeof(a));
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define sqr(a) a*a
const double eps=1e-8;
const int N = 111111;
const int mod = 1000000;
const double pi=acos(-1.0);
typedef long long ll;
const ll INF = 0x7f7f7f7f;
const double inf = 1e50;
template<class T> inline T minx(T a,T b) { return (a==-1||b<a)?b:a; }
template<class T> inline T gcd(T a,T b) { return b?gcd(b,a%b):a;}
template<class T> inline T lcm(T a,T b) { return a*(b/gcd(a,b));}
template<class T> inline T getbit(T n) { return n?(1+getbit(n&(n-1))):0;}
template<class T> inline T lowbit(T n) { return n&(-n);}
using namespace std;
typedef long long ll;
int c[N];
int a[N];
int b[N];
int cnt[N];
set<int>s[N];
int main()
{
	int n,m;
	int i,j,k;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			if(m==0) return 0;
			m--;
			printf("%d",i+1);
			for(k=1;k<=i;k++)
			{
				printf(" %d",a[k]);
			}
			printf(" %d\n",a[j]);
		}
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<string>
#include<algorithm>
#include<iterator>
#include<set>
#include<deque>
#include<cctype>
#include<cassert>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<stack>
#include<bitset>
#include<map>
#include<utility>
#include<ctime>
#define clr(a,v) memset(a,v,sizeof(a));
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define sqr(a) a*a
const double eps=1e-8;
const int N = 111111;
const int mod = 1000000;
const double pi=acos(-1.0);
typedef long long ll;
const ll INF = 0x7f7f7f7f;
const double inf = 1e50;
template<class T> inline T minx(T a,T b) { return (a==-1||b<a)?b:a; }
template<class T> inline T gcd(T a,T b) { return b?gcd(b,a%b):a;}
template<class T> inline T lcm(T a,T b) { return a*(b/gcd(a,b));}
template<class T> inline T getbit(T n) { return n?(1+getbit(n&(n-1))):0;}
template<class T> inline T lowbit(T n) { return n&(-n);}
using namespace std;
typedef long long ll;
int c[N],a[N];
int cnt[N];
set<int>s[N];
map<ll,ll>p;
map<ll,ll>::iterator it;
int n,k;
void dfs(ll sum,int t,ll s)
{
	if(t>=n) return;
	int size=p.size();
	if(size>=k) return;
	if(sum>0&&s>0)
	{
		p[sum]=s;
	}
	int i;
	for(i=t+1;i<=n;i++)
	{
		dfs(sum+a[i],t+1,s|(1ll<<i));
	}
}
int main()
{
	ll t=1;
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)
	{
		scanf("%d",a+i);
	}
	sort(a+1,a+n+1);
	dfs(0,0,0);
	ll b;
	int st[100];
	int size;
	int cnt=0;
	for(it=p.begin();it!=p.end();it++)
	{
		cnt++;
		size=0;
		b=it->second;
		if(!b) continue;
		for(j=1;j<=n;j++)
		{
			if(b&(t<<j))
			{
				st[size++]=a[j];
			}
		}
		printf("%d",size);
		for(j=0;j<size;j++) printf(" %d",st[j]);
		puts("");
		if(cnt==k) break;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<string>
#include<algorithm>
#include<iterator>
#include<set>
#include<deque>
#include<cctype>
#include<cassert>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<stack>
#include<bitset>
#include<map>
#include<utility>
#include<ctime>
#define clr(a,v) memset(a,v,sizeof(a));
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define sqr(a) a*a
const double eps=1e-8;
const int N = 111111;
const int mod = 1000000;
const double pi=acos(-1.0);
typedef long long ll;
const ll INF = 0x7f7f7f7f;
const double inf = 1e50;
template<class T> inline T minx(T a,T b) { return (a==-1||b<a)?b:a; }
template<class T> inline T gcd(T a,T b) { return b?gcd(b,a%b):a;}
template<class T> inline T lcm(T a,T b) { return a*(b/gcd(a,b));}
template<class T> inline T getbit(T n) { return n?(1+getbit(n&(n-1))):0;}
template<class T> inline T lowbit(T n) { return n&(-n);}
using namespace std;
typedef long long ll;
int c[N],a[N];
int cnt[N];
set<int>s[N];
map<ll,ll>p;
map<ll,ll>::iterator it;
int n,k;
void dfs(ll sum,int t,ll s)
{
	if(sum>0&&s>0&&!p[sum])
	{
		p[sum]=s;
	}
	if(p.size()>=k) return;
	for(int i=t;i<n;i++)
	{
		dfs(sum+a[i],i+1,s|(1ll<<i));
	}
}
int main()
{
	ll t=1;
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	sort(a,a+n);
	dfs(0,0,0);
	ll b;
	int st[100];
	int size;
	int cnt=0;
	for(it=p.begin();it!=p.end();it++)
	{
		cnt++;
		size=0;
		b=it->second;
		if(!b) continue;
		for(j=0;j<n;j++)
		{
			if(b&(1ll<<j))
			{
				st[size++]=a[j];
			}
		}
		printf("%d",size);
		for(j=0;j<size;j++) printf(" %d",st[j]);
		puts("");
		if(cnt==k) break;
	}
	return 0;
}


#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<cmath>
#include<string>
#include<algorithm>
#include<iterator>
#include<set>
#include<deque>
#include<cctype>
#include<cassert>
#include<vector>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<stack>
#include<bitset>
#include<map>
#include<utility>
#include<ctime>
#define clr(a,v) memset(a,v,sizeof(a));
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define sqr(a) a*a
const double eps=1e-8;
const int N = 111111;
const int mod = 1000000;
const double pi=acos(-1.0);
typedef long long ll;
const ll INF = 0x7f7f7f7f;
const double inf = 1e50;
template<class T> inline T minx(T a,T b) { return (a==-1||b<a)?b:a; }
template<class T> inline T gcd(T a,T b) { return b?gcd(b,a%b):a;}
template<class T> inline T lcm(T a,T b) { return a*(b/gcd(a,b));}
template<class T> inline T getbit(T n) { return n?(1+getbit(n&(n-1))):0;}
template<class T> inline T lowbit(T n) { return n&(-n);}
using namespace std;
typedef long long ll;
int c[N],a[N];
int cnt[N];
set<int>s[N];
map<ll,ll>p;
map<ll,ll>::iterator it;
int n,k;
void dfs(ll sum,int t,ll s)
{
	if(sum>0&&s>0)
	{
		p[sum]=s;
	}
	if(p.size()>k) return;
	for(int i=t;i<n;i++)
	{
		dfs(sum+a[i],i+1,s|(1ll<<i));
	}
}
int main()
{
	ll t=1;
	int i,j;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)
	{
		scanf("%d",a+i);
	}
	sort(a,a+n);
	dfs(0,0,0);
	ll b;
	int st[100];
	int size;
	int cnt=0;
	for(it=p.begin();it!=p.end();it++)
	{
		cnt++;
		size=0;
		b=it->second;
		if(!b) continue;
		for(j=0;j<n;j++)
		{
			if(b&(1ll<<j))
			{
				st[size++]=a[j];
			}
		}
		printf("%d",size);
		for(j=0;j<size;j++) printf(" %d",st[j]);
		puts("");
		if(cnt==k) break;
	}
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <climits>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <list>
#include <cstring>
#include <map>
using namespace std;

// <editor-fold defaultstate="collapsed" desc="Defines">

typedef long long ll;
typedef unsigned long long ull;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
const double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
#define REP(to, counter) for (int counter=0; counter < int(to); counter++)
#define X first
#define PB push_back
#define MP make_pair
#define Y second
#define eps 1E-7

inline vi ReadVI(int count)
{
    vi arrayname(count);
    REP(count, i) cin >> arrayname[i];
    return arrayname;
};

inline vii ReadVII(int count)
{
    vii arrayname(count);

    REP(count, i)
    {
        cin >> arrayname[i].first;
        arrayname[i].second = i;
    }
    return arrayname;
};

const int MOD = 1000000007;
const int MAXVALUE = 101;

// </editor-fold >

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    vi s = ReadVI(n);
    sort(s.begin(), s.end());

    int count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s.size() - i; j++, printf("\n")) {
            printf("%d ", i + 1);
            for (int p = s.size() - i; p < s.size(); p++) printf("%d ", s[p]);
            printf("%d ", s[j]);
            count++;
            if (count >= k) return 0;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll      long long
#define mp      make_pair
#define sz(v)   (int)v.size()
#define pb      push_back
#define b_p(n)      __builtin_popcount(n)
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector <int> v(n);
    for(int i=0;i<n;i++)
        scanf("%d",&v[i]);

    for(int i=1;i<=n;i++){
        if(k==0)
            break;
        for(int x=0;x<=n-i;x++,k--){
            if(k==0)
                break;
            cout<<i<<" ";
            for(int z=x;z<x+i;z++){
                if(k==0)
                    break;
                cout<<v[z]<<" ";
            }
            if(k==0)
                break;
            cout<<endl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll      long long
#define mp      make_pair
#define sz(v)   (int)v.size()
#define pb      push_back
#define b_p(n)      __builtin_popcount(n)
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    vector <int> v(n);
    for(int i=0;i<n;i++)
        scanf("%d",&v[i]);

    sort(v.rbegin(),v.rend());

    for(int i=1;i<=n;i++){
        for(int j=i-1;j<n;j++,k--){
            if(k==0)
                return 0;
            cout<<i<<" "<<v[j]<<" ";
            for(int x=0;x<i-1;x++)
                cout<<v[x]<<" ";

            cout<<endl;
        }
    }
    return 0;
}


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

int a[55],b[2000],sum[55];
int comp(const void *p,const void *q){
    return *(int *)q-*(int *)p;
}
int main(){
    int n,m,k,i,j,x,y;

    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),comp);
    memset(sum,0,sizeof(sum));
    for(i=0;i<n;i++){
        sum[i+1]=sum[i];
        sum[i+1]+=a[i];
        //printf("%d ",sum[i+1]);
    }
    m=0;x=1;
    while(m<k){
        for(j=x-1;j<n;j++){
            printf("%d ",x);
            for(i=0;i<x-1;i++)printf("%d ",a[i]);
            printf("%d\n",a[j]);
            m++;
        }
        x++;
    }

    return 0;
}


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

int a[55],b[2000],sum[55];
int comp(const void *p,const void *q){
    return *(int *)q-*(int *)p;
}
int main(){
    int n,m,k,i,j,x,y;

    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),comp);

    m=0;x=1;
    while(m<k){
        for(j=x-1;j<n && m<k;j++){
            printf("%d ",x);
            for(i=0;i<x-1;i++)printf("%d ",a[i]);
            printf("%d\n",a[j]);
            m++;
        }
        x++;
    }

    return 0;
}


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

int a[55],b[2000],sum[55];
int comp(const void *p,const void *q){
    return *(int *)q-*(int *)p;
}
int main(){
    int n,m,k,i,j,x,y;

    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    qsort(a,n,sizeof(int),comp);
    memset(sum,0,sizeof(sum));
    for(i=0;i<n;i++){
        sum[i+1]=sum[i];
        sum[i+1]+=a[i];
        //printf("%d ",sum[i+1]);
    }
    m=0;x=1;
    while(m<k){
        for(i=0;i<n-x+1 && m<k;i++){
            y=sum[i+x]-sum[i];
            for(j=0;j<m;j++)if(y==b[j])break;
            if(j<m)continue;
            printf("%d ",x);
            for(j=0;j<x;j++)printf("%d ",a[i+j]);
            printf("\n");
            b[m++]=y;
        }
        x++;
    }

    return 0;
}


// editorial is used
#include <cstdio>
#include <iostream>

#include <vector>
#include <list>
#include <string>
#include <set>

#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

const int MAXN = 100;
const int MAXK = 2000;

int n, k;
int xs[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 0 ; i < n; ++i)
        cin >> xs[i];
    sort(xs, xs + n, greater<int>());

    int day = 0;
    for(int i = 0; day < k && i < n; ++i, ++day)
        cout << "1 " << xs[i] << endl;

    for(int i = 1; day < k && i < n; ++i) {
        for(int j = i; day < k && j < n; ++j, ++day) {
            cout << i + 1;
            for(int t = 0; t < i; ++t)
                cout << ' ' << xs[t];
            cout << ' ' << xs[j] << endl;
        }
    }

    return 0;
}


// editorial is used
#include <cstdio>
#include <iostream>

#include <vector>
#include <list>
#include <string>
#include <set>

#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

const int MAXN = 100;
const int MAXK = 2000;

int n, k;
int xs[MAXN];

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 0 ; i < n; ++i)
        cin >> xs[i];
    sort(xs, xs + n, greater<int>());

    int j = 0;
    for(int i = 0; j < k && i < n; ++i, ++j)
        cout << "1 " << xs[i] << endl;

    for(int i = 0; j < k && i < n - 1; ++i, ++j) {
        cout << i + 2;
        for(int t = 0; t <= i; ++t)
            cout << ' ' << xs[t];
        cout << ' ' << xs[i + 1] << endl;
    }

    return 0;
}


#include <cstdio>
#include <iostream>

#include <vector>
#include <list>
#include <string>
#include <set>

#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

const int MAXN = 100;
const int MAXK = 2000;

int n, k;
int xs[MAXN];

void go(int &day, vector<int> &group,
        int value, set<int> &used)
{
    if(day <= k) {
        if(used.find(value) == used.end()) {
            cout << group.size();
            for(size_t i = 0; i < group.size(); ++i)
                cout << ' ' << group[i];
            cout << endl;

            used.insert(value);
            ++day;
        }

        for(int i = 0; i < n; ++i)
            if(group.back() < xs[i]) {
                group.push_back(xs[i]);
                go(day, group, value + xs[i], used);
                group.pop_back();
            }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 0; i < n; ++i)
        cin >> xs[i];
    sort(xs, xs + n);

    int day = 1;
    vector<int> group;
    set<int> used;

    group.reserve(2000);

    for(int i = 0; day <= k && i < n; ++i) {
        group.push_back(xs[i]);
        go(day, group, xs[i], used);
        group.pop_back();
    }

    return 0;
}


#include <cstdio>
#include <iostream>

#include <vector>
#include <list>
#include <string>
#include <set>

#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

const int MAXN = 100;
const int MAXK = 2000;

int n, k;
int xs[MAXN];

void go(int &day, vector<int> &group,
        vector<int> &sums, set<int> &used)
{
    if(day <= k) {
        for(size_t i = 0; day <= k && i < group.size(); ++i) {
            int s = sums.back();
            if(0 < i)
                s -= sums[i - 1];

            if(used.find(s) == used.end()) {
                cout << group.size() - i;
                for(size_t j = i; j < group.size(); ++j)
                    cout << ' ' << group[j];
                cout << endl;

                ++day;
                used.insert(s);
            }
        }

        for(int i = 0; i < n; ++i)
            if(group.back() < xs[i]) {
                group.push_back(xs[i]);
                sums.push_back(sums.back() + xs[i]);

                go(day, group, sums, used);

                sums.pop_back();
                group.pop_back();
            }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 0; i < n; ++i)
        cin >> xs[i];
    sort(xs, xs + n);

    int day = 1;
    vector<int> group;
    vector<int> sums;
    set<int> used;

    group.reserve(MAXK);
    sums.reserve(MAXK);

    group.push_back(xs[0]);
    sums.push_back(xs[0]);

    go(day, group, sums, used);

    return 0;
}


#include <cstdio>
#include <iostream>

#include <vector>
#include <list>
#include <string>
#include <set>

#include <algorithm>
#include <functional>
#include <cmath>

using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

const int MAXN = 100;
const int MAXK = 2000;

int n, k;
int xs[MAXN];

void go(int &day, vector<int> &group,
        int value, set<int> &used)
{
    if(day <= k) {
        if(used.find(value) == used.end()) {
            cout << group.size();
            for(size_t i = 0; i < group.size(); ++i)
                cout << ' ' << group[i];
            cout << endl;

            used.insert(value);
            ++day;
        }

        for(int i = 0; i < n; ++i)
            if(group.back() < xs[i]) {
                group.push_back(xs[i]);
                go(day, group, value + xs[i], used);
                group.pop_back();
            }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i = 0; i < n; ++i)
        cin >> xs[i];
    sort(xs, xs + n);

    int day = 1;
    vector<int> group;
    set<int> used;

    for(int i = 0; day <= k && i < n; ++i) {
        group.push_back(xs[i]);
        go(day, group, xs[i], used);
        group.pop_back();
    }

    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
    int n,kk;
    while(scanf("%d%d",&n,&kk)!=EOF)
    {
        int num[111]={0};
        for(int i=0;i<n;i++)
          scanf("%d",&num[i]);
        sort(num,num+n);
        for(int i=n;i>=1;i--)
        {
           for(int j=0;j<i;j++)
           {
               printf("%d %d",n-i+1,num[j]);
               for(int k=i;k<n;k++)
                 printf(" %d",num[k]);
               puts("");
               kk--;
               if(kk<=0)
                  goto loop;
           }
        }
        loop:;
    }
    return 0;
}


#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
using namespace std;

#define nln        puts("")                         ///prLLInewline
#define getLLI(a)  scanf("%d",&a);
#define max3(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define min3(a,b,c) min(a,min(b,c))                  ///3 ta theke min

#define FOR1(i,n)  for(LLI i=1;i<=n;i++)
#define FOR0(i,n)  for(LLI i=0;i<n;i++)                 ///looping
#define FORR(i,n)  for(LLI i=n-1;i>=0;i--)
#define ALL(p)     p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define SZ(c)      (LLI)c.size()
#define PB(x)      push_back(x)                     ///STL defines
#define MP(x,y)    make_pair(x,y)
#define ff         first
#define ss         second

#define LI         long LLI
#define LLI        long long// LLI
#define f64        long double
#define PI         acos(-1.0)                        ///PI er value

LLI Set(LLI N,LLI pos)
{
    return N=N | (1<<pos);
}
LLI reset(LLI N,LLI pos)
{
    return N= N & ~(1<<pos);
}
bool check(LLI N,LLI pos)
{
    return (bool)(N & (1<<pos));
}
void CI(LLI &_x)
{
    scanf("%I64d",&_x);
}

void CO(LLI &_x)
{
    cout<<_x;
}

template<typename T> void getarray(T a[],LLI n)
{
    for(LLI i=0; i<n; i++) cin>>a[i];
}
template<typename T> void prLLIarray(T a[],LLI n)
{
    for(LLI i=0; i<n-1; i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

const double EPS=1e-9;                              ///constatnts
const LLI INF=0x7f7f7f7f;

LLI dr8[8]= {1,-1,0,0,1,-1,-1,1};            ///8 direction move
LLI dc8[8]= {0,0,-1,1,1,1,-1,-1};
LLI dr4[4]= {0,0,1,-1};                      ///4 direction move
LLI dc4[4]= {-1,1,0,0};                      ///or adjacent dir.
LLI kn8r[8]= {1,2,2,1,-1,-2,-2,-1};          ///knight moves
LLI kn8c[8]= {2,1,-1,-2,-2,-1,1,2};
vector<int>V;

int main()
{
    int n,k,temp;

    cin>>n>>k;
    FOR0(i,n)
    {
        cin>>temp;
        V.PB(temp);
    }
    sort(ALL(V));
    int mini=min(n,k);
    for(int i=0; i<mini; i++)
    {
        cout<<"1 "<<V[i]<<"\n";

    }
    k=k-mini;

    if(k>0)
    {
        for(int i=n-1; i>=0&&k; i--)
        {
            for(int j=i-1; j>=0&&k; j--)
            {
               cout<<n-i+1;
               for(int k=i;k<n;k++){

                cout<<" "<<V[k];
               }
              cout<<" "<<V[j]<<"\n";
                 k--;
            }

        }

    }

}


#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
using namespace std;

#define nln        puts("")                         ///prLLInewline
#define getLLI(a)  scanf("%d",&a);
#define max3(a,b,c) max(a,max(b,c))                  ///3 ta theke max
#define min3(a,b,c) min(a,min(b,c))                  ///3 ta theke min

#define FOR1(i,n)  for(LLI i=1;i<=n;i++)
#define FOR0(i,n)  for(LLI i=0;i<n;i++)                 ///looping
#define FORR(i,n)  for(LLI i=n-1;i>=0;i--)
#define ALL(p)     p.begin(),p.end()

#define SET(p)     memset(p,-1,sizeof(p))
#define CLR(p)     memset(p,0,sizeof(p))            ///memset
#define MEM(p,v)   memset(p,v,sizeof(p))

#define READ(f)    freopen(f, "r", stdin)           /// file
#define WRITE(f)   freopen(f, "w", stdout)

#define SZ(c)      (LLI)c.size()
#define PB(x)      push_back(x)                     ///STL defines
#define MP(x,y)    make_pair(x,y)
#define ff         first
#define ss         second

#define LI         long LLI
#define LLI        long long// LLI
#define f64        long double
#define PI         acos(-1.0)                        ///PI er value

LLI Set(LLI N,LLI pos)
{
    return N=N | (1<<pos);
}
LLI reset(LLI N,LLI pos)
{
    return N= N & ~(1<<pos);
}
bool check(LLI N,LLI pos)
{
    return (bool)(N & (1<<pos));
}
void CI(LLI &_x)
{
    scanf("%I64d",&_x);
}

void CO(LLI &_x)
{
    cout<<_x;
}

template<typename T> void getarray(T a[],LLI n)
{
    for(LLI i=0; i<n; i++) cin>>a[i];
}
template<typename T> void prLLIarray(T a[],LLI n)
{
    for(LLI i=0; i<n-1; i++) cout<<a[i]<<" ";
    cout<<a[n-1]<<endl;
}

const double EPS=1e-9;                              ///constatnts
const LLI INF=0x7f7f7f7f;

LLI dr8[8]= {1,-1,0,0,1,-1,-1,1};            ///8 direction move
LLI dc8[8]= {0,0,-1,1,1,1,-1,-1};
LLI dr4[4]= {0,0,1,-1};                      ///4 direction move
LLI dc4[4]= {-1,1,0,0};                      ///or adjacent dir.
LLI kn8r[8]= {1,2,2,1,-1,-2,-2,-1};          ///knight moves
LLI kn8c[8]= {2,1,-1,-2,-2,-1,1,2};
vector<int>V;

int main()
{
    int n,k,temp;

    cin>>n>>k;
    FOR0(i,n)
    {
        cin>>temp;
        V.PB(temp);
    }
    sort(ALL(V));
    int mini=min(n,k);
    for(int i=0; i<mini; i++)
    {
        cout<<"1 "<<V[i]<<"\n";

    }
    k=k-mini;

    if(k>0)
    {
        for(int i=n-1; i>=0&&k; i++)
        {
            for(int j=i-1; j>=0&&k; j--)
            {
               cout<<n-i;
               for(int k=i;k<n;k++){

                cout<<" "<<V[k];
               }
              cout<<" "<<V[j]<<"\n";
                 k--;
            }

        }

    }

}


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

using namespace std;
int main()
{
    //freopen("output.txt","w",stdout);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > v(n, pair<int, int>());
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].first;
        v[i].second = i + 1;
    }
    sort(v.begin(), v.end());
    int sum = 0;
    int cnt = 0;
    vector<int> ans;
    reverse(v.begin(), v.end());
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            cnt++;
            cout << i + 1 << ' ';
            for (int l = 0; l < ans.size(); l++)
                cout << ans[l] << ' ';
            cout << v[j].first << '\n';
            if (cnt == k)
                return 0;
        }
        ans.push_back(v[i].first);
    }
    return 0;
}


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

using namespace std;
int main()
{
    //freopen("output.txt","w",stdout);
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > v(n, pair<int, int>());
    for (int i = 0; i < n; i++)
    {
        cin >> v[i].first;
        v[i].second = i + 1;
    }
    sort(v.begin(), v.end());
    int sum = 0;
    int cnt = 0;
    vector<int> ans;
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            cnt++;
            cout << i + 1 << ' ';
            for (int l = 0; l < ans.size(); l++)
                cout << ans[l] << ' ';
            cout << v[j].first << '\n';
            if (cnt == k)
                return 0;
        }
        ans.push_back(v[i].first);
    }
    return 0;
}


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

int main(void)
{
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (auto& x: v)
        cin >> x;
    sort(v.rbegin(), v.rend());
    for (int i = 0, j = 0, t = 1; i < k; ++i, ++j)
    {
        if (j >= n)
        {
            ++t;
            j = t-1;
        }
        cout << t << ' ';
        for (int u = 0; u < t-1; ++u)
            cout << v[u] << ' ';
        cout << v[j] << endl;
    }
    return 0;
}


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

struct sold
{
    int val, ind;
};

bool cmp(const sold& A, const sold& B)
{
    return A.val<B.val;
}

int main()
{
    int n, k;
    cin >> n >> k;
    sold *A=new sold[n];
    for(int i=0; i<n; i++)
    {
        cin >> A[i].val;
        A[i].ind=i+1;
    }

    sort(A, A+n, cmp);
    int left=k;
    for(int i=0; i<n; i++)
    {
        if(left==0) break;
        cout << 1 << ' ' << A[i].val << '\n';
        left--;
    }
    for(int szEnd=1; szEnd<n; szEnd++)
    {
        int lastEnd=n-szEnd;
        for(int i=0; i<lastEnd; i++)
        {
            if(left==0) break;
            cout << szEnd + 1 << ' ' << A[i].val << ' ';
            for(int temp=lastEnd; temp<n; temp++) cout << A[temp].val << ' ';
            cout << '\n';
            left--;
        }
        if(left==0) break;
    }

    delete[] A;
    return 0;
}


#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <algorithm>
#include <assert.h>
using namespace std;

void smain();
int main(){
    ios_base::sync_with_stdio(0);
#ifdef DEBUG
    freopen("input.txt","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef DEBUG
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define fori(i,a) for(auto i=a.begin(); i!=a.end(); ++i)
#define rfori(i,a) for(auto i=a.rbegin(); i!=a.rend(); ++i)
#define int long long
#define LL long long
#define mp(a,b) make_pair(a,b)
#define INF 0x7fffffff
#define MOD 1000000007
#define EPS 0.00000001
#define N 100
/* --------- END TEMPLATE CODE --------- */

int n, k, m, a[N];

void smain(){
    cin >> n >> k;
    forn(i, n) cin >> a[i];
    sort(a, a + n);
    set<int> was;

    forn(i, min(n, k)) cout << 1 << ' ' << a[i] << endl, was.insert(a[i]);
    for(int i = 1; was.size() < k && i <= n; ++i){
        int s = 0;
        for(int j=0; j < i; ++j) s += a[n - 1 - j];
        for(int j=0; j < n - i; ++j) if(was.count(s + a[j]) == 0){
            was.insert(s + a[j]);
            cout << i + 1 << ' ';
            for(int j=0; j < i; ++j) cout << a[n - 1 - j] << ' ';
            cout << a[j] << endl;
        }
    }
}


#include <iostream>
#include <cstring>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstdlib>
#include <algorithm>
#include <assert.h>
using namespace std;

void smain();
int main(){
    ios_base::sync_with_stdio(0);
#ifdef DEBUG
    freopen("input.txt","rt",stdin);
    const clock_t start = clock();
#endif
    smain();
#ifdef DEBUG
    cerr << "\nTotal Execution Time: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

#define forn(i,n) for (int i=0;i<n;i++)
#define rforn(i,n) for (int i=n-1;i>=0;i--)
#define fori(i,a) for(auto i=a.begin(); i!=a.end(); ++i)
#define rfori(i,a) for(auto i=a.rbegin(); i!=a.rend(); ++i)
#define int long long
#define LL long long
#define mp(a,b) make_pair(a,b)
#define INF 0x7fffffff
#define MOD 1000000007
#define EPS 0.00000001
#define N 100
/* --------- END TEMPLATE CODE --------- */

int n, k, m, a[N];

void smain(){
    cin >> n >> k;
    forn(i, n) cin >> a[i];
    sort(a, a + n);
    set<int> was;

    forn(i, min(n, k)) cout << 1 << ' ' << a[i] << endl, was.insert(a[i]);
    for(int i = 1; was.size() < k && i <= n; ++i){
        int s = 0;
        for(int j=0; j < i; ++j) s += a[n - 1 - j];
        for(int j=0; was.size() < k && j < n - i; ++j) if(was.count(s + a[j]) == 0){
            was.insert(s + a[j]);
            cout << i + 1 << ' ';
            for(int j=0; j < i; ++j) cout << a[n - 1 - j] << ' ';
            cout << a[j] << endl;
        }
    }
}


#include <iostream>
#include <algorithm>

int n, k;
int a[50];
int ans[50];

void select(int len, int cur, int start) {
  if (len == cur) {
    if (k-- > 0) {
      std::cout << len << " ";
      for (int i = 0; i < len; ++i) std::cout << ans[i] << " ";
      std::cout << std::endl;
    }
    return;
  }

  for (int i = start; i < n; ++i) {
    ans[cur] = a[i];
    select(len, cur + 1, i + 1);
  }
}

int main() {
  std::cin >> n >> k;

  for (int i = 0; i < n; ++i) std::cin >> a[i];

  std::sort(a, a + n);

  for (int i = 0; k > 0 && i < n; ++i, --k) {
    std::cout << "1 ";
    std::cout << a[i] << std::endl;
  }

  for (int len = 1; k > 0 && len <= n; ++len) {
    for (int j = 0; k > 0 && j < n - len; ++j, --k) {
      std::cout << (len + 1) << std::endl;
      for (int i = n - len; i < n; ++i) {
        std::cout << a[i] << " ";
      }
      std::cout << a[j] << std::endl;
    }
  }

}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
set<int> used;
int main()
{
    int mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n,greater<int>());
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used.find(temp)==used.end())
        {
            used.insert(temp);
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
set<int64> used;
int main()
{
    int64 mask,i,j,n,a[55],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    //sort(a,a+n,greater<int64>());
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used.find(temp)==used.end())
        {
            used.insert(temp);
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
set<int> used;
int main()
{
    srand(time(NULL));
    int i,n,a[55],k,ans=0,temp,c;
    int64 mask,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    //sort(a,a+n,greater<int64>());
    for(;;)
    {
        mask=0;
        while(mask==0)mask=rand()%(1<<n);
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used.find(temp)==used.end())
        {
            used.insert(temp);
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
map<int,bool> used;
int main()
{

    int64 mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n);
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(!used[temp])
        {
            used[temp]=1;
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
map<int,int> used;
int main()
{
    int mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=1;i<=n;i++)
      cin>>a[i];
    sort(a+1,a+n+1,greater<int>());

    for(i=1;i<=n;i++)
    {
        for(j=i;j<=n;j++)
        {
            ans++;
            cout<<i<<' ';
            for(int k=1;k<i;k++)
              cout<<a[k]<<' ';
            cout<<a[j]<<' ';
        cout<<endl;
        if(ans==k)return 0;
        }
    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
map<int,int> used;
int main()
{
    int64 mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    sort(a,a+n,greater<int>());
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used[temp]==0)
        {
            used[temp]=1;
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
map<int,bool> used;
int main()
{

    int64 mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(!used[temp])
        {
            used[temp]=1;
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
map<int,bool> used;
int main()
{

    int64 mask,i,j,n,a[51],k,ans=0,temp,c;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    for(mask=1;mask<(1<<n);mask++)
    {
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(!used[temp])
        {
            used[temp]=1;
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<j+1<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
set<int> used;
int main()
{
    srand(time(NULL));
    int i,n,a[55],k,ans=0,temp,c;
    int64 mask,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    //sort(a,a+n,greater<int64>());
    for(;;)
    {
        mask=0;
        while(mask==0)mask=rand()%(1<<n);
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used.find(temp)==used.end())
        {
            used.insert(temp);
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;
}


#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<ctime>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#include<cmath>

#define nx(x) (x | (x+1))
#define pr(x) (x & (x+1))

#define x first
#define MAXN 200005
#define y second
#define all(c) (c).begin(),(c).end()
#define mp make_pair
//#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long int64;
set<int> used;
int main()
{
    srand(time(NULL));
    int i,n,a[55],k,ans=0,temp,c;
    int64 mask,j;
    cin>>n>>k;
    for(i=0;i<n;i++)
      cin>>a[i];
    random_shuffle(a,a+n);
    //sort(a,a+n,greater<int64>());
    for(;;)
    {
        mask=0;
        while(mask==0)mask=rand()%(1<<n);
        //cout<<mask<<endl;
        temp=0;c=0;
        for(j=0;j<n;j++)
          if(mask&(1<<j))
            temp+=a[j],c++;
        if(used.find(temp)==used.end())
        {
            used.insert(temp);
            ans++;
            cout<<c<<' ';
            for(j=0;j<n;j++)
              if(mask&(1<<j))
                 cout<<a[j]<<' ';
            cout<<endl;
            if(ans==k)return 0;
        }

    }

return 0;

return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define space " "
#define ast "**"
using namespace std;

int main(){
 int n,k;
 int a[100];
vector<int> v;
 cin >>n >> k;
for(int i = 0 ;i < n;i++) cin >> a[i];

sort(a,a+n);

int c = 0;
for(int i = 1 ; i <= n && c < k;i++){
    for(int j = 0 ; j <= n-i && c < k;j++){
        v.push_back(a[j]);
        for(int r = 0 ,mm = j; r < i-1; r++){
            v.push_back(a[n-r-1]);
        }
cout<<v.size()<<space;
for(int l = 0 ; l < v.size() ; l++)cout<<v[l]<<space;cout<<endl;
    v.clear();c++;

    }
}
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define space " "
#define ast "**"
using namespace std;

int main(){
 int n,k;
 int a[100];
vector<int> v;
 cin >>n >> k;
for(int i = 0 ;i < n;i++) cin >> a[i];
int c = 0;
for(int i = 1 ; i <= n && c < k;i++){
    for(int j = 0 ; j < n && c < k;){
        for(int r = 0 ; r < i && j < n; r++)
            v.push_back(a[j]),j++;
cout<<v.size()<<space;
for(int l = 0 ; l < v.size() ; l++)cout<<v[l]<<space;cout<<endl;
    v.clear();c++;

    }
}
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#define space " "
#define ast "**"
using namespace std;

int main(){
 int n,k;
 int a[100];
vector<int> v;
 cin >>n >> k;
for(int i = 0 ;i < n;i++) cin >> a[i];

int c = 0;
for(int i = 1 ; i < n && c < k;i++){
    for(int j = 0 ; j < n && c < k;){
        for(int r = 0 ; r < i && j < n; r++)
                v.push_back(a[j]),j++;
cout<<v.size()<<space;
for(int l = 0 ; l < v.size() ; l++)cout<<v[l]<<space;cout<<endl;
    v.clear();c++;

    }
}
    return 0;
}


#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int N;
int M;
int mas[100000];
long long beat[50][50];
bool used[50][50] ;
int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++) cin>> mas[i];
    for(int i=0;i<N;i++){
        beat[i][i] = mas[i];
        used[i][i] = false;
    }
    for(int i=0;i<N;i++){
        for(int j =1;j<N;j++){
            used[i][j] = false;
            beat[i][j] = beat[i][j-1] + mas[j];
        }
    }
    int counter = 0;
        for(int k =0;k<N&&counter<M;k++){
            for(int j =k;j<N&&counter<M;j++){
                if (!used[k][j]){
                    used[k][j] = true;
                    counter++;
                    cout << j-k+1 ;
                    for(int p = 0;p<j-k+1;p++){
                        cout <<" " << mas[k+p];
                    }
                    cout << endl;
                    long long tmp = beat[k][j];
                    for(int r =0;r<N;r++){
                        for(int z =0;z<N;z++){
                            if (tmp==beat[r][z]) used[r][z] = true;
                        }
                    }
                }
            }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int N;
int M;
int mas[100000];
long long beat[50][50];
long long sumz[1225];
bool used[1225] ;
int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++) cin>> mas[i];
    for(int i=0;i< (N*(N-1)/2;i++){

    }
    for(int i=0;i<N;i++){
        for(int j =i+1;j<N;j++){
            used[j][i] = false;
            beat[j][i] = beat[j-1][j-1] + mas[j];
        }
    }
    int counter = 0;
        for(int k =0;k<N&&counter<M;k++){
            for(int j =k;j<N&&counter<M;j++){
                if (!used[k][j]){
                    used[k][j] = true;
                    counter++;
                    cout << j-k+1 ;
                    for(int p = 0;p<j-k+1;p++){
                        cout <<" " << mas[k+p];
                    }
                    cout << endl;
                    long long tmp = beat[k][j];
                    for(int r =0;r<N;r++){
                        for(int z =r;z<N;z++){
                            if (tmp==beat[r][z]) used[r][z] = true;
                        }
                    }
                }
            }
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int N;
int M;
int mas[100000];
long long sumz[2500];
map <long long , int > suma;

void printsold(long long zum){
    int scol =0;
    long long tmp = zum;
    while(zum>0){
        scol++;
        zum = zum - mas[suma[zum]];
    }
    cout << scol ;
    zum = tmp;
    while(zum>0){
        cout << " " << mas[suma[zum]] ;
        zum = zum - mas[suma[zum]];
    }
    cout << endl;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++) cin>> mas[i];
    int cc = 0;
    sumz[0]=0;
    int days =0;
    for(int i =0;i<N&&days<M;i++){
        int tmp = cc;
        while(tmp>=0){
        sumz[cc++] = mas[i]+sumz[tmp];
        if (suma.count(sumz[cc-1])==0) {
                suma[sumz[cc-1]]= i;
                printsold(sumz[cc-1]);
                days++;
                if (days==M) break;
            }
        tmp--;
        }
    }

    return 0;
}


#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int N;
int M;
int mas[100000];
long long sumz[2500];
map <long long , int > suma;

void printsold(long long zum){
    int scol =0;
    long long tmp = zum;
    while(zum>0){
        scol++;
        zum = zum - mas[suma[zum]];
    }
    cout << scol ;
    zum = tmp;
    while(zum>0){
        cout << " " << mas[suma[zum]] ;
        zum = zum - mas[suma[zum]];
    }
    cout << endl;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++) cin>> mas[i];
    int cc = 0;
    sumz[0]=0;
    int days =0;
    for(int i =0;i<N&&days<M;i++){
        int tmp = cc;
        while(tmp>=0){
        long long chsm = mas[i]+sumz[tmp] ;
        if (suma.count(chsm)==0) {
                sumz[cc++] = mas[i]+sumz[tmp];
                suma[sumz[cc-1]]= i;
                printsold(sumz[cc-1]);
                days++;
                if (days==M) break;
            }
        tmp--;
        }
    }

    return 0;
}


#include <iostream>
#include <cmath>
#include <map>

using namespace std;

int N;
int M;
int mas[100000];
long long sumz[2500];
map <long long , int > suma;

void printsold(long long zum){
    int scol =0;
    long long tmp = zum;
    while(zum>0){
        scol++;
        zum = zum - mas[suma[zum]];
    }
    cout << scol ;
    zum = tmp;
    while(zum>0){
        cout << " " << mas[suma[zum]] ;
        zum = zum - mas[suma[zum]];
    }
    cout << endl;
}

int main(){
    cin>>N>>M;
    for(int i=0;i<N;i++) cin>> mas[i];
    int cc = 0;
    sumz[0]=0;
    int days =0;
    for(int i =0;i<N&&days<M;i++){
        int tmp = cc;
        while(tmp>=0){
        sumz[cc++] = mas[i]+sumz[tmp];
        if (suma.count(sumz[cc-1])==0) {
                suma[sumz[cc-1]]= i;
                printsold(sumz[cc-1]);
                days++;
            }
        tmp--;
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <cassert>
#include <numeric>
#include <sstream>
using namespace std;

#define REQUIRE(cond, message) \
    do { \
        if (!(cond)) { \
            std::cerr << message << std::endl; \
            assert(false); \
        } \
    } while (false)

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define forv(i, v) forn(i, v.size())
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef vector<string> vs;
typedef long double ld;

const int INF = std::numeric_limits<int>::max();
const char* IN_FILE = ".in";
const char* OUT_FILE = ".out";

void solve()
{
    int n; cin >> n;
    int k; cin >> k;
    vi a(n); forn(i, n) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    vi ans;
    forn(i, n) {
        if (k == 0) break;
        for (int j = i; j < n; ++j) {
            if (k == 0) break;
            --k;
            cout << ans.size() + 1;
            forv(u, ans) cout << " " << ans[u];
            cout << " " << a[j] << endl;
        }
        ans.pb(a[i]);
    }
}

void init()
{
    freopen(IN_FILE, "rt", stdin);
    freopen(OUT_FILE, "wt", stdout);
}

int main()
{
    ios_base::sync_with_stdio(false);
//    init();
    solve();
    return 0;
}


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

int main() {
    int n , k;
    scanf("%d %d" , &n , &k);
    vector<int> V(n);

    for(auto &x : V)
        scanf("%d" , &x);

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

    int num = 0;
    for(int i = 0 ; i < n && num != k ; ++i , ++num)
        printf("1 %d\n"  , V[i]);

    for(int i = n - 1 ; i >= 0 && num != k ; --i){
        for(int j = i - 1 ; j >= 0 && num != k ; --j , ++num) {
            printf("%d " , n - i + 1);
            for(int l = n - 1 ; l >= i ; --l){
                printf("%d " , V[l]);
            }
            printf("%d\n" , V[j]);
        }
    }
    return 0;
}