#include<bits/stdc++.h>
using namespace std ;
vector<char> v[5] = {
{'b', 'c'},
{'a', 'c', 'd'},
{'a', 'b', 'd', 'e'},
{'b', 'c', 'e'},
{'c', 'd'},
};
char starting = 'a', ending = 'e' ;
bool visited [5] ;
vector<char> ans ;
bool dfs (char c) {
visited[c - 'a'] = true ;
ans.push_back(c) ;
if (c == ending) {
return true ;
}
for (auto i : v[c - 'a']) {
if (!visited[i - 'a']) {
if (dfs(i)) {
return true ;
}
}
}
ans.pop_back() ;
return false ;
}
int main () {
if (dfs(starting)) {
for (auto &i : ans) {
cout << i << " " ;
}
}
else {
cout << "Can't reach the Ending point" ;
}
return 0 ;
}
/*
* answer is :[ a b c d e ]
*/
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7Cgp2ZWN0b3I8Y2hhcj4gdls1XSA9IHsKICAgICAgICB7J2InLCAnYyd9LAogICAgICAgIHsnYScsICdjJywgJ2QnfSwKICAgICAgICB7J2EnLCAnYicsICdkJywgJ2UnfSwKICAgICAgICB7J2InLCAnYycsICdlJ30sCiAgICAgICAgeydjJywgJ2QnfSwKICAgICAgICAgICAgICAgICAgICAgfTsKCmNoYXIgc3RhcnRpbmcgPSAnYScsIGVuZGluZyA9ICdlJyA7CmJvb2wgdmlzaXRlZCBbNV0gOwp2ZWN0b3I8Y2hhcj4gYW5zIDsKCmJvb2wgZGZzIChjaGFyIGMpIHsKICAgIHZpc2l0ZWRbYyAtICdhJ10gPSB0cnVlIDsKICAgIGFucy5wdXNoX2JhY2soYykgOwoKICAgIGlmIChjID09IGVuZGluZykgewogICAgICAgIHJldHVybiB0cnVlIDsKICAgIH0KCiAgICBmb3IgKGF1dG8gaSA6IHZbYyAtICdhJ10pIHsKICAgICAgICBpZiAoIXZpc2l0ZWRbaSAtICdhJ10pIHsKICAgICAgICAgICAgaWYgKGRmcyhpKSkgewogICAgICAgICAgICAgICAgcmV0dXJuIHRydWUgOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIGFucy5wb3BfYmFjaygpIDsKICAgIHJldHVybiBmYWxzZSA7Cn0KCmludCBtYWluICgpIHsKICAgIGlmIChkZnMoc3RhcnRpbmcpKSB7CiAgICAgICAgZm9yIChhdXRvICZpIDogYW5zKSB7CiAgICAgICAgICAgIGNvdXQgPDwgaSA8PCAiICIgOwogICAgICAgIH0KICAgIH0KICAgIGVsc2UgewogICAgICAgIGNvdXQgPDwgIkNhbid0IHJlYWNoIHRoZSBFbmRpbmcgcG9pbnQiIDsKICAgIH0KICAgIHJldHVybiAwIDsKfQoKLyoKICogYW5zd2VyIGlzIDpbIGEgYiBjIGQgZSBdCiAqLw==