n = int(input())
trouglovi = [list(map(int, input().split())) for _ in range(n - 4)]
veze = []
veze.append([1, 2])
veze.append([2, 3])
veze.append([3, 1])
for i, t in enumerate(trouglovi, start=4):
    a, b, c = t
    veze.append([i + 1, a])
    veze.append([i + 1, b])
    veze.append([i + 1, c])
putanja = []
poseceni = set()
stack = [1]
while stack:
    tekuci = stack.pop()
    if tekuci not in poseceni:
        poseceni.add(tekuci)
        putanja.append(tekuci)
        for v in veze:
            x, y = v
            if x == tekuci and y not in poseceni:
                stack.append(y)
            elif y == tekuci and x not in poseceni:
                stack.append(x)
if len(putanja) == n and any(1 == v[0] and putanja[-1] == v[1] or 1 == v[1] and putanja[-1] == v[0] for v in veze):
    putanja.append(1)
    print(" ".join(map(str, putanja)))
else:
    print(-1)