class GRAF():
    def __init__(self, ivice):
        self.matrica_susedstva = [[0 for x in range(ivice)] for y in range(ivice)]
        self.ivice = ivice
        
    def bezbedno_dodati(self, v, pos, put):
        if self.matrica_susedstva[put[pos-1]][v] == 0:
            return False
        for cvor in put:
            if cvor == v:
                return False

        return True
        
        
    def hamilt_util(self, put, pos):
        if pos == self.ivice:
            if self.matrica_susedstva[put[pos-1]][put[0]] == 1:
                return True
            else:
                return False

        for v in range(1, self.ivice):
            if self.bezbedno_dodati(v, pos, put):
                put[pos] = v
                if self.hamilt_util(put, pos+1):
                    return True
                put[pos] = -1
        return False

    def nadji_hamilt(self):
        put = [-1] * self.ivice
        put[0] = 0
        if not self.hamilt_util(put, 1):
            print(-1)
            return False
        for cvor in put:
            print(cvor+1, end=' ', sep=' ')
        print(1)
        return True

n = int(input())

g = GRAF(n)

g.matrica_susedstva[0][1], g.matrica_susedstva[1][0] = 1, 1
g.matrica_susedstva[0][2], g.matrica_susedstva[2][0] = 1, 1
g.matrica_susedstva[1][2], g.matrica_susedstva[2][1] = 1, 1
g.matrica_susedstva[3][0], g.matrica_susedstva[0][3] = 1, 1
g.matrica_susedstva[3][1], g.matrica_susedstva[1][3] = 1, 1
g.matrica_susedstva[3][2], g.matrica_susedstva[2][3] = 1, 1

for i in range(4, n):
    a, b, c = map(int, input().split())
    a-=1
    b-=1
    c-=1
    for j in [a,b,c]:
        g.matrica_susedstva[i][j], g.matrica_susedstva[j][i] = 1, 1

g.nadji_hamilt()