#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector> Graph(N); for(int i=0; i> s; if(s == "H") continue; int u = stoi(s)-1; Graph.at(u).push_back(i); } } auto dfs = [&](auto dfs,int pos,int back) -> void { for(auto to : Graph.at(pos)){ if(to == back) continue; cout << "("; dfs(dfs,to,pos); cout << ")"; } if(back == -1) cout << "methane\n"; else cout << "methyl"; }; dfs(dfs,0,-1); }