#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define endl "\n"
using namespace std;
class graph
{
vector <int> visit(12);
map < int,vector<int> > mp;
public:
void addedge(int x,int y)
{
mp[x].push_back(y);
mp[y].push_back(x);
}
void dfs_helper(int src)
{
cout<<src<<" ";
for(auto e:mp[src])
{
if(visit[e]==0)
{
visit[e]=1;
dfs_helper(e);
}
}
}
void dfs()
{
int count=0;
for(int i=0;i<12;i++)
{
if(visit[i]==0)
{
count++;
visit[i]=1;
dfs_helper(i);
cout<<endl;
}
}
cout<<count<<endl;
}
};
int32_t main()
{
graph g;
g.addedge(0,4);
g.addedge(0,3);
g.addedge(3,2);
g.addedge(2,1);
g.addedge(0,1);
g.addedge(5,6);
g.addedge(6,7);
g.addedge(8,9);
g.addedge(10,11);
g.dfs();
return 0;
}