import sys input = sys.stdin.read sys.setrecursionlimit(300000) visited = [False] * 300001 def dfs(u): visited[u] = True b = sorted(dfs(v) for v in adj[u] if not visited[v]) return "methane" if not b else "".join("(" + x[:-3] + "yl)" for x in b) + "methane" d = input().split() N = int(d[0]) adj = [[] for _ in range(N + 1)] index = 1 for i in range(1, N + 1): for _ in range(4): n = d[index] index += 1 if n != 'H': n = int(n) if n != i: adj[i].append(n) print(dfs(1))