#include using namespace std; using ll=long long; constexpr int MOD=998244353; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep2(i,l,r) for(int i=(l);i<(int)(r);i++) void dfs(const vector>& A,int v,int p,string& ret,int root=0){ if(!root){ ret+='('; } rep(i,4){ if(A[v][i]!=p&&A[v][i]!=-1){ dfs(A,A[v][i],v,ret); } } if(root){ ret+="methane"; }else{ ret+="methyl)"; } return; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin>>N; vector A(N,array()); rep(i,N){ rep(j,4){ string S; cin>>S; if(S=="H"){ A[i][j]=-1; }else{ A[i][j]=stoi(S)-1; } } } string ans=""; dfs(A,0,-1,ans,1); cout<