#include #include #include using namespace std; int main () { int N; cin >> N; vector> graph(N); for (int i = 0; i < N; i++) { for (int j = 0; j < 4; j++) { string str; cin >> str; int to; try { to = stoi(str) - 1; } catch (...) { continue; } graph[i].push_back(to); } } auto dfs = [&] (auto self, int pos, int par) -> string { string res = ""; for (auto nex: graph[pos]) { if (nex == par) continue; auto name = self(self, nex, pos); res += "(" + name.substr(0, name.size() - 3) + "yl)"; } res += "methane"; return res; }; cout << dfs(dfs, 0, -1) << "\n"; }