#include
#include
#include
#include
using namespace std;
template
class Graph{
map<T,list >l;
public:
void addEdge(int x,int y){
l[x].push_back(y);
l[y].push_back(x);
}
void dfs_helper(map<T,bool>&visited,T src){
cout<<src<<" ";
visited[src]=true;
for(auto nbr : l[src]){
if(!visited[nbr]){
dfs_helper(visited,src);
}
}
}
void dfs(T src){
map<T,bool>visited;
for(auto p:l){
visited[p.first]=false;
}
dfs_helper(visited,src);
}
};
int main(){
Graph g;
g.addEdge(0,1);
g.addEdge(1,2);
g.addEdge(2,3);
g.addEdge(3,4);
g.addEdge(4,5);
g.addEdge(3,0);
g.dfs(0);
}