#include using namespace std; using ll=long long; using pll=pair; using tll=tuple; using ld=long double; const ll INF=(1ll<<60); #define rep(i,n) for (ll i=0;i<(ll)(n);i++) #define all(v) v.begin(),v.end() template inline bool chmin(T &a,T b){ if(a>b){ a=b; return true; } return false; } template inline bool chmax(T &a,T b){ if(a> g; vector vis; string ans; void dfs(ll x){ if(vis[x]) return; vis[x]=true; if(x!=0) ans+="("; for(auto i:g[x]){ dfs(i); } if(x!=0) ans+="methyl)"; else ans+="methane"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); ll n; cin >> n; g.resize(n); vis.resize(n,false); rep(i,n){ rep(j,4){ string s; cin >> s; if(s!="H"){ ll x=stoll(s); x--; g[i].push_back(x); } } } dfs(0); cout << ans << '\n'; }