#include using namespace std; int main(){ int N; cin >> N; vector> G(N); for (int i = 0; i < N; i++){ for (int j = 0; j < 4; j++){ string s; cin >> s; if (s != "H"){ int v = stoi(s) - 1; G[i].push_back(v); } } } auto dfs = [&](auto dfs, int v, int c) -> string { string T; if (v != 0){ T += '('; } for (int i : G[v]){ if (i == c){ continue; } T += dfs(dfs, i, v); } if (v != 0){ T += "methyl)"; } return T; }; string ans = dfs(dfs, 0, -1) + "methane"; cout << ans << endl; }