#include using namespace std; #define all(v) (v).begin(),(v).end() #define pb(a) push_back(a) #define rep(i, n) for(int i=0;i> n; vector> v(n); rep(i, n) { rep(j, 4) { string s; cin >> s; if(s != "H") { int a = stoi(s) - 1; v[i].pb(a); } } } auto dfs = [&](auto dfs, int now, int p) -> void { if(p != -1) { cout << "("; } foa(e, v[now]) { if(e == p) continue; dfs(dfs, e, now); } if(p == -1) { cout << "methane" << endl; } else { cout << "methyl)"; } }; dfs(dfs, 0, -1); return 0; }