def poseceno(i, m, res, pos):
    if m[res[pos - 1]][i] == 0:
        return False
    
    if i in res:
        return False
    
    return True

def fun(m, res, pos):
    if pos == n:
        return m[res[pos - 1]][res[0]] == 1
    
    for i in range(n):
        if poseceno(i, m, res, pos):
            res[pos] = i

            if fun(m, res, pos+1):
                return True
            
            res[pos] = -1
    
    return False


n = int(input())

m = []

for i in range(n):
    m.append([])
    for j in range(n):
        if i == j or i > 3 or j > 3:
            m[i].append(0)
        else:
            m[i].append(1)

for i in range(4, n):
    l = list(map(int, input().split()))
    for j in range(3):
        m[i][l[j]-1] = 1
        m[l[j]-1][i] = 1


res = [-1] * n

res[0] = 0

if fun(m, res, 1):
    res.append(0)
    for i in range(n+1):
        print(res[i]+1, end=' ')
else:
    print(-1)