![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/7d4f375f0530ca9f5ce40dbef75a9204.png)
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
const int N=100+5;
int n,m;
int a[N];
map<vector<int>,int>mp;
struct node{
vector<int>v;
int cnt;
};
bool cmp(node a,node b){
if(a.cnt==b.cnt){
for(int i=0;i<m;i++){
if(a.v[i]==b.v[i]) continue;
return a.v[i]<b.v[i];
}
}
return a.cnt>b.cnt;
}
void solve(){
cin>>n>>m;
vector<int>a(N);
for(int i=1;i<=n;i++){
for(int j=0;j<m;j++) cin>>a[j];
mp[a]++;
}
vector<node>res;
for(auto it:mp){
res.push_back({it.first,it.second});
}
sort(res.begin(),res.end(),cmp);
cout<<res.size()<<endl;
for(auto it:res){
cout<<it.cnt;
for(int i=0;i<m;i++){
cout<<" "<<it.v[i];
}
cout<<endl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t=1;
while(t--) solve();
return 0;
}