#include <bits/stdc++.h>
using namespace std;
//Definitions for quicker writing
#define REP(i,a,b) for (int i = a; i < b; i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
//Typedefs for quicker writing
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
typedef pair<long long, long long> pl;
//Max values
const long long lmx = LLONG_MAX;
const int imx = INT_MAX;
vector<bool> viscur(500,false);
vector<vector<bool>> used;
bool dfs(int cur, vector<vi> &adj, vector<vi> &paths){
viscur[cur] = true;
for(auto next: adj[cur]){
if(viscur[next] == true){
return false;
}
else if(viscur[next] == false && !used[cur][next]){
if(!dfs(next,vector<vi> &adj, vector<vi> &paths)){
return false;
}
else{
used[cur][next] = true;
}
}
}
return true;
}
int main() {
//IO optimization
ios::sync_with_stdio(0);
cin.tie(0);
//Input definition
int n;
int m;
//Read In
cin >> n >> m;
vector<vi> adj;
vector<vi> paths;
int a,b;
REP(i,0,m){
cin >> a >> b;
adj[a].PB(b);
used[a][b] = false;
}
//Main part
while(dfs(0,vector<vi> &adj, vector<vi> &paths)){
REP(i,1,500) viscur[i] = false;
}
//Write out
cout << paths.size() << "\n";
REP(i,0,paths.size()){
cout << paths[i].size() << "\n";
REP(j,0,paths[i].size()){
cout << paths[i][j] << " ";
}
cout << endl;
}
//Return
return 0;
}