#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); } } } string ans; auto dfs = [&](auto dfs, int v, int c) -> void { if (v != 0){ ans += '('; } for (int i : G[v]){ if (i == c){ continue; } dfs(dfs, i, v); } if (v != 0){ ans += "methyl)"; } }; dfs(dfs, 0, -1); ans += "methane"; cout << ans << endl; }